org.objectweb.proactive.core.body.request
Class BlockingRequestQueueImpl

java.lang.Object
  |
  +--org.objectweb.proactive.core.event.AbstractEventProducer
        |
        +--org.objectweb.proactive.core.body.request.RequestQueueImpl
              |
              +--org.objectweb.proactive.core.body.request.BlockingRequestQueueImpl
All Implemented Interfaces:
BlockingRequestQueue, RequestQueue, java.io.Serializable
Direct Known Subclasses:
ComponentRequestQueueImpl, ImplicitService

public class BlockingRequestQueueImpl
extends RequestQueueImpl
implements java.io.Serializable, BlockingRequestQueue

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.objectweb.proactive.core.event.AbstractEventProducer
AbstractEventProducer.ListenerList
 
Field Summary
static org.apache.log4j.Logger logger
           
protected  boolean shouldWait
           
 
Fields inherited from class org.objectweb.proactive.core.body.request.RequestQueueImpl
ownerID, requestQueue, SEND_ADD_REMOVE_EVENT
 
Fields inherited from class org.objectweb.proactive.core.event.AbstractEventProducer
eventListeners, shouldSerializeListeners
 
Constructor Summary
BlockingRequestQueueImpl(UniqueID ownerID)
           
 
Method Summary
 void add(Request r)
          Adds the given request to the end of the queue
 void addToFront(Request r)
          Adds the given request to the front of the queue before all other request already in the queue
protected  Request blockingRemove(boolean oldest)
          Blocks the calling thread until there is a request available Returns immediately if there is already one.
protected  Request blockingRemove(long timeout, boolean oldest)
          Blocks the calling thread until there is a request available but try to limit the time the thread is blocked to timeout.
protected  Request blockingRemove(RequestFilter requestFilter, boolean oldest)
           
protected  Request blockingRemove(java.lang.String methodName, boolean oldest)
          Blocks the calling thread until there is a request of name methodName Returns immediately if there is already one.
 Request blockingRemoveOldest()
          Blocks the calling thread until there is a request available Returns immediately if there is already one.
 Request blockingRemoveOldest(long timeout)
          Blocks the calling thread until there is a request available but try to limit the time the thread is blocked to timeout.
 Request blockingRemoveOldest(RequestFilter requestFilter)
          Blocks the calling thread until there is a request that can be accepted be the given RequestFilter.
 Request blockingRemoveOldest(java.lang.String methodName)
          Blocks the calling thread until there is a request of name methodName Returns immediately if there is already one.
 Request blockingRemoveYoungest()
          Blocks the calling thread until there is a request available Returns immediately if there is already one.
 Request blockingRemoveYoungest(long timeout)
          Blocks the calling thread until there is a request available but try to limit the time the thread is blocked to timeout.
 Request blockingRemoveYoungest(RequestFilter requestFilter)
          Blocks the calling thread until there is a request that can be accepted be the given RequestFilter.
 Request blockingRemoveYoungest(java.lang.String methodName)
          Blocks the calling thread until there is a request of name methodName Returns immediately if there is already one.
 void destroy()
          Destroys this BlockingQueue by removing all its content, unblocking all thread waiting for a request and making sure that no thread will block again.
 boolean isDestroyed()
          Returns if this BlockingQueue is destroyed
 void waitForRequest()
          Blocks the calling thread until there is a request available.
 
Methods inherited from class org.objectweb.proactive.core.body.request.RequestQueueImpl
addRequestQueueEventListener, clear, getOldest, getOldest, getOldest, getYoungest, getYoungest, getYoungest, hasRequest, isEmpty, iterator, notifyOneListener, processRequests, removeOldest, removeOldest, removeOldest, removeRequestQueueEventListener, removeYoungest, removeYoungest, removeYoungest, size, toString
 
Methods inherited from class org.objectweb.proactive.core.event.AbstractEventProducer
addListener, hasListeners, notifyAllListeners, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.objectweb.proactive.core.body.request.RequestQueue
addRequestQueueEventListener, clear, getOldest, getOldest, getOldest, getYoungest, getYoungest, getYoungest, hasRequest, isEmpty, iterator, processRequests, removeOldest, removeOldest, removeOldest, removeRequestQueueEventListener, removeYoungest, removeYoungest, removeYoungest, size
 

Field Detail

logger

public static org.apache.log4j.Logger logger

shouldWait

protected boolean shouldWait
Constructor Detail

BlockingRequestQueueImpl

public BlockingRequestQueueImpl(UniqueID ownerID)
Method Detail

destroy

public void destroy()
Description copied from interface: BlockingRequestQueue
Destroys this BlockingQueue by removing all its content, unblocking all thread waiting for a request and making sure that no thread will block again. After this call, any call to a blocking method won't block and return null.

Specified by:
destroy in interface BlockingRequestQueue

isDestroyed

public boolean isDestroyed()
Description copied from interface: BlockingRequestQueue
Returns if this BlockingQueue is destroyed

Specified by:
isDestroyed in interface BlockingRequestQueue

add

public void add(Request r)
Description copied from interface: RequestQueue
Adds the given request to the end of the queue

Specified by:
add in interface RequestQueue
Overrides:
add in class RequestQueueImpl
Parameters:
r - the request to add

addToFront

public void addToFront(Request r)
Description copied from interface: RequestQueue
Adds the given request to the front of the queue before all other request already in the queue

Specified by:
addToFront in interface RequestQueue
Overrides:
addToFront in class RequestQueueImpl
Parameters:
r - the request to add

blockingRemoveOldest

public Request blockingRemoveOldest(RequestFilter requestFilter)
Description copied from interface: BlockingRequestQueue
Blocks the calling thread until there is a request that can be accepted be the given RequestFilter. Returns immediately if there is already one. The request returned is non null unless the thread has been asked not to wait anymore.

Specified by:
blockingRemoveOldest in interface BlockingRequestQueue
Parameters:
requestFilter - the request filter that select the request to be returned
Returns:
the oldest request found in the queue that is accepted by the filter.

blockingRemoveOldest

public Request blockingRemoveOldest(java.lang.String methodName)
Description copied from interface: BlockingRequestQueue
Blocks the calling thread until there is a request of name methodName Returns immediately if there is already one. The request returned is non null unless the thread has been asked not to wait anymore.

Specified by:
blockingRemoveOldest in interface BlockingRequestQueue
Parameters:
methodName - the name of the method to wait for
Returns:
the oldest request of name methodName found in the queue.

blockingRemoveOldest

public Request blockingRemoveOldest()
Description copied from interface: BlockingRequestQueue
Blocks the calling thread until there is a request available Returns immediately if there is already one. The request returned is non null unless the thread has been asked not to wait anymore.

Specified by:
blockingRemoveOldest in interface BlockingRequestQueue
Returns:
the oldest request found in the queue.

blockingRemoveOldest

public Request blockingRemoveOldest(long timeout)
Description copied from interface: BlockingRequestQueue
Blocks the calling thread until there is a request available but try to limit the time the thread is blocked to timeout. Returns immediately if there is already one. The request returned is non null if a request has been found during the given time.

Specified by:
blockingRemoveOldest in interface BlockingRequestQueue
Returns:
the oldest request found in the queue or null.

blockingRemoveYoungest

public Request blockingRemoveYoungest(RequestFilter requestFilter)
Description copied from interface: BlockingRequestQueue
Blocks the calling thread until there is a request that can be accepted be the given RequestFilter. Returns immediately if there is already one. The request returned is non null unless the thread has been asked not to wait anymore.

Specified by:
blockingRemoveYoungest in interface BlockingRequestQueue
Parameters:
requestFilter - the request filter that select the request to be returned
Returns:
the youngest request found in the queue that is accepted by the filter.

blockingRemoveYoungest

public Request blockingRemoveYoungest(java.lang.String methodName)
Description copied from interface: BlockingRequestQueue
Blocks the calling thread until there is a request of name methodName Returns immediately if there is already one. The request returned is non null unless the thread has been asked not to wait anymore.

Specified by:
blockingRemoveYoungest in interface BlockingRequestQueue
Parameters:
methodName - the name of the method to wait for
Returns:
the youngest request of name methodName found in the queue.

blockingRemoveYoungest

public Request blockingRemoveYoungest()
Description copied from interface: BlockingRequestQueue
Blocks the calling thread until there is a request available Returns immediately if there is already one. The request returned is non null unless the thread has been asked not to wait anymore.

Specified by:
blockingRemoveYoungest in interface BlockingRequestQueue
Returns:
the youngest request found in the queue.

blockingRemoveYoungest

public Request blockingRemoveYoungest(long timeout)
Description copied from interface: BlockingRequestQueue
Blocks the calling thread until there is a request available but try to limit the time the thread is blocked to timeout. Returns immediately if there is already one. The request returned is non null if a request has been found during the given time.

Specified by:
blockingRemoveYoungest in interface BlockingRequestQueue
Returns:
the youngest request found in the queue or null.

waitForRequest

public void waitForRequest()
Description copied from interface: BlockingRequestQueue
Blocks the calling thread until there is a request available. The request is not removed from the queue. Returns immediately if there is already one.

Specified by:
waitForRequest in interface BlockingRequestQueue

blockingRemove

protected Request blockingRemove(RequestFilter requestFilter,
                                 boolean oldest)

blockingRemove

protected Request blockingRemove(java.lang.String methodName,
                                 boolean oldest)
Blocks the calling thread until there is a request of name methodName Returns immediately if there is already one. The request returned is non null unless the thread has been asked not to wait anymore.

Parameters:
methodName - the name of the method to wait for
oldest - true if the request to remove is the oldest, false for the youngest
Returns:
the request of name methodName found in the queue.

blockingRemove

protected Request blockingRemove(boolean oldest)
Blocks the calling thread until there is a request available Returns immediately if there is already one. The request returned is non null unless the thread has been asked not to wait anymore.

Parameters:
oldest - true if the request to remove is the oldest, false for the youngest
Returns:
the request found in the queue.

blockingRemove

protected Request blockingRemove(long timeout,
                                 boolean oldest)
Blocks the calling thread until there is a request available but try to limit the time the thread is blocked to timeout. Returns immediately if there is already one. The request returned is non null if a request has been found during the given time.

Parameters:
timeout - the maximum time to wait
oldest - true if the request to remove is the oldest, false for the youngest
Returns:
the request found in the queue or null.


Copyright © April 2004 INRIA All Rights Reserved.