public class BlockingQueue<T> extends java.lang.Object implements BlockingQueue4<T>
| Modifier and Type | Field and Description |
|---|---|
protected Lock4 |
_lock |
protected NonblockingQueue<T> |
_queue |
protected boolean |
_stopped |
| Constructor and Description |
|---|
BlockingQueue() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(T obj) |
int |
drainTo(Collection4<T> target)
Removes all the available elements in the queue to the colletion passed
as argument.
|
boolean |
hasNext() |
Iterator4<T> |
iterator() |
T |
next() |
T |
next(long timeout)
Returns the next queued item or waits for it to be available for the
maximum of
timeout miliseconds. |
T |
nextMatching(Predicate4<T> condition)
Returns the next object in the queue that matches the specified condition.
|
void |
stop() |
protected void |
unsafeWaitForNext() |
protected boolean |
unsafeWaitForNext(long timeout) |
void |
waitForNext() |
boolean |
waitForNext(long timeout) |
protected NonblockingQueue<T> _queue
protected Lock4 _lock
protected boolean _stopped
public T next(long timeout) throws BlockingQueueStoppedException
BlockingQueue4
Returns the next queued item or waits for it to be available for the
maximum of timeout miliseconds.
next in interface BlockingQueue4<T>timeout - maximum time to wait for the next avilable item in milisecondsnull if timeout is
reachedBlockingQueueStoppedException - if the BlockingQueue4.stop() is called.public int drainTo(Collection4<T> target)
BlockingQueue4Removes all the available elements in the queue to the colletion passed as argument.
It will block until at least one element is available.
drainTo in interface BlockingQueue4<T>public boolean waitForNext(long timeout)
throws BlockingQueueStoppedException
BlockingQueueStoppedExceptionpublic T next() throws BlockingQueueStoppedException
next in interface Queue4<T>BlockingQueueStoppedExceptionpublic void stop()
stop in interface BlockingQueue4<T>public T nextMatching(Predicate4<T> condition)
Queue4nextMatching in interface Queue4<T>condition - the object must satisfy to be returnedpublic void waitForNext()
throws BlockingQueueStoppedException
BlockingQueueStoppedExceptionprotected void unsafeWaitForNext()
throws BlockingQueueStoppedException
BlockingQueueStoppedExceptionprotected boolean unsafeWaitForNext(long timeout)
throws BlockingQueueStoppedException
BlockingQueueStoppedException