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

java.lang.Object
  extended byorg.objectweb.proactive.core.event.AbstractEventProducer
      extended byorg.objectweb.proactive.core.body.request.RequestQueueImpl
          extended byorg.objectweb.proactive.core.body.request.BlockingRequestQueueImpl
All Implemented Interfaces:
BlockingRequestQueue, RequestQueue, java.io.Serializable
Direct Known Subclasses:
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.body.request.RequestQueueImpl
RequestQueueImpl.RequestFilterOnMethodName
 
Nested classes inherited from class org.objectweb.proactive.core.event.AbstractEventProducer
AbstractEventProducer.ListenerList
 
Field Summary
protected  boolean shouldWait
           
 
Fields inherited from class org.objectweb.proactive.core.body.request.RequestQueueImpl
ownerID, requestFilterOnMethodName, requestQueue, SEND_ADD_REMOVE_EVENT
 
Fields inherited from class org.objectweb.proactive.core.event.AbstractEventProducer
eventListeners, logger, shouldSerializeListeners
 
Constructor Summary
BlockingRequestQueueImpl(UniqueID ownerID)
           
 
Method Summary
 int add(Request r)
          Adds the given request to the end of the queue
 int addToFront(Request r)
          Adds the given request to the front of the queue before all other request already in the queue
protected  Request barrierBlockingRemove()
          Blocks the calling thread until there is a request available Returns immediately if there is already one.
protected  Request barrierBlockingRemoveOldest(long timeout)
          Blocks the calling thread until there is a request available Returns immediately if there is already one.
protected  Request barrierRemoveOldest()
           
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(RequestFilter requestFilter, boolean oldest, long timeout)
           
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(RequestFilter requestFilter, long timeout)
          Blocks the calling thread until there is a request that can be accepted be the given RequestFilter but tries to limit the time the thread is blocked to timeout.
 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(RequestFilter requestFilter, long timeout)
          Blocks the calling thread until there is a request that can be accepted be the given RequestFilter, but tries to limit the time the thread is blocked to timeout.
 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 resume()
          Resumes the service of requests.
 void suspend()
          Blocks the service of requests.
 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, getInternalQueue, 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, getInternalQueue, getOldest, getOldest, getOldest, getYoungest, getYoungest, getYoungest, hasRequest, isEmpty, iterator, processRequests, removeOldest, removeOldest, removeOldest, removeRequestQueueEventListener, removeYoungest, removeYoungest, removeYoungest, size
 

Field Detail

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 int 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

addToFront

public int 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

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(RequestFilter requestFilter,
                                    long timeout)
Description copied from interface: BlockingRequestQueue
Blocks the calling thread until there is a request that can be accepted be the given RequestFilter but tries 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.

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(RequestFilter requestFilter,
                                      long timeout)
Description copied from interface: BlockingRequestQueue
Blocks the calling thread until there is a request that can be accepted be the given RequestFilter, but tries to limit the time the thread is blocked to timeout. 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(RequestFilter requestFilter,
                                 boolean oldest,
                                 long timeout)

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.

barrierBlockingRemoveOldest

protected Request barrierBlockingRemoveOldest(long timeout)
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.

Returns:
the request found in the queue.

barrierRemoveOldest

protected Request barrierRemoveOldest()

barrierBlockingRemove

protected Request barrierBlockingRemove()
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.

Returns:
the request found in the queue.

suspend

public void suspend()
Blocks the service of requests. Incoming requests are still added in queue.

Specified by:
suspend in interface BlockingRequestQueue

resume

public void resume()
Resumes the service of requests.

Specified by:
resume in interface BlockingRequestQueue


Copyright 2001-2005 INRIA All Rights Reserved.