Package org.jbrew.concurrent
Interface TaskQueue<T extends Task<? extends java.lang.Object>>
- Type Parameters:
T
- - The type ofTask
. The full type parameter in the interface's signature is:
<T extends
.Task
<? extendsObject
>>
- All Known Implementing Classes:
AbstractBlockingTaskQueue
,BoundedTaskQueue
,UnboundedTaskQueue
public interface TaskQueue<T extends Task<? extends java.lang.Object>>
A TaskQueue is a set of ordered or unordered
Task
s placed into a custom
queue which can be operated by producers or consumers in one or more Thread
.- Author:
- nealk
-
Method Details
-
enqueue
Adds an element to the head of the queue. When the queue is full (bounded implementations only), the callingThread
is blocked until capacity in the queue has been released.- Parameters:
task
- - TheTask
which is being added to the queue.- Throws:
java.lang.InterruptedException
- - The method hands off the responsibility of exception handling to the caller in event of an interruption in theThread
.
-
dequeue
Removes an element from the tail of the queue and returns it. If the queue is empty, the callingThread
is blocked until aTask
is added to the queue and it is no longer empty.- Returns:
- The
Task
which is being removed from the queue. - Throws:
java.lang.InterruptedException
- - The method hands off the responsibility of exception handling to the caller in event of an interruption in theThread
.
-