guarana.toolkit.engine
Class WorkQueue
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
java.util.concurrent.PriorityBlockingQueue<WorkUnit>
guarana.toolkit.engine.WorkQueue
- All Implemented Interfaces:
- Serializable, Iterable<WorkUnit>, Collection<WorkUnit>, BlockingQueue<WorkUnit>, Queue<WorkUnit>
public class WorkQueue
- extends PriorityBlockingQueue<WorkUnit>
A priority queue that contains work units ready to be executed.
- Since:
- Guaranį SDK 1.0.0
- Author:
- Rafael Z. Frantz
- See Also:
- Serialized Form
Constructor Summary |
WorkQueue()
Constructs a new work queue. |
Methods inherited from class java.util.concurrent.PriorityBlockingQueue |
clear, comparator, contains, drainTo, drainTo, iterator, offer, offer, peek, poll, put, remainingCapacity, remove, size, take, toArray, toArray, toString |
serialVersionUID
public static final long serialVersionUID
- See Also:
- Constant Field Values
WorkQueue
public WorkQueue()
- Constructs a new work queue.
add
public boolean add(WorkUnit element)
throws InvalidParameterException
- Adds an element to this queue.
- Specified by:
add
in interface Collection<WorkUnit>
- Specified by:
add
in interface BlockingQueue<WorkUnit>
- Specified by:
add
in interface Queue<WorkUnit>
- Overrides:
add
in class PriorityBlockingQueue<WorkUnit>
- Parameters:
element
- The element to be added to this queue.
- Returns:
- boolean to indicate if the element could be added.
- Throws:
InvalidParameterException
- if the parameter is null
.
poll
public WorkUnit poll()
- Polls an element from the queue. This method also removes the element
from this queue. A call to this method will block the caller till an
element can be returned or till the system stops by calling
releaseWaitingThreads()
.
- Specified by:
poll
in interface Queue<WorkUnit>
- Overrides:
poll
in class PriorityBlockingQueue<WorkUnit>
- Returns:
- the polled element or
null
in case there is no more
elements and releaseWaitingThreads()
is called. - See Also:
releaseWaitingThreads()
releaseWaitingThreads
public int releaseWaitingThreads()
- Releases all threads which have polled this queue and are waiting for an
element. This method must be called when the system has stopped and no
more elements will be received by this queue.
- Returns:
- the number of workers that were waiting.
getQueuedTaskNames
public Set<String> getQueuedTaskNames()
- Returns all the names of tasks waiting in this queue.
- Returns:
- a list of all the task names.
Guaranį DSL Home