com.waveset.util
Class BlockingQueue
java.lang.Object
com.waveset.util.Queue
com.waveset.util.SynchronizedQueue
com.waveset.util.BlockingQueue
- public class BlockingQueue
- extends SynchronizedQueue
Method Summary |
java.lang.Object |
dequeue()
|
java.lang.Object |
dequeue(boolean waitIfEmpty)
|
void |
enqueue(java.lang.Object obj)
Add the specified item to the back of the queue. |
static void |
main(java.lang.String[] args)
|
void |
notifyAllWaiters()
Notify all of the callers waiting to dequeue. |
java.lang.Object |
waitToDequeue()
|
java.lang.Object |
waitToDequeue(long timeout)
|
void |
waitToEnqueue(java.lang.Object obj,
int queueSizeLimit)
Add the specified item to the back of the queue. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
code_id
public static final java.lang.String code_id
- See Also:
- Constant Field Values
trace
protected static final Trace trace
_waitForItemToBeRead
protected Semaphore _waitForItemToBeRead
BlockingQueue
public BlockingQueue()
waitToDequeue
public java.lang.Object waitToDequeue()
throws java.lang.InterruptedException
- Returns:
- the next item from the front of the queue.
If the queue is empty, this method blocks
until the caller is notified or interrupted.
- Throws:
java.lang.InterruptedException
waitToDequeue
public java.lang.Object waitToDequeue(long timeout)
throws java.lang.InterruptedException
- Returns:
- the next item from the front of the queue.
If the queue is empty, this method blocks
until the caller is notified or interrupted or the timeout expires.
- Throws:
java.lang.InterruptedException
dequeue
public java.lang.Object dequeue(boolean waitIfEmpty)
throws java.lang.InterruptedException
- Overrides:
dequeue
in class SynchronizedQueue
- Parameters:
waitIfEmpty
- if true
, causes the method to block
until the caller is notified or interrupted.
- Returns:
- the next item from the front of the queue.
- Throws:
java.lang.InterruptedException
- if the thread is interrupted
while waiting.
dequeue
public java.lang.Object dequeue()
- Overrides:
dequeue
in class Queue
- Returns:
- the next item from the front of the queue.
waitToEnqueue
public void waitToEnqueue(java.lang.Object obj,
int queueSizeLimit)
throws java.lang.InterruptedException
- Add the specified item to the back of the queue.
If the queue is larger than @param queueSizeLimit,
this method blocks until the caller is notified
or the caller is interrupted.
- Throws:
java.lang.InterruptedException
enqueue
public void enqueue(java.lang.Object obj)
- Add the specified item to the back of the queue.
Notify one of the callers waiting to dequeue.
- Overrides:
enqueue
in class SynchronizedQueue
notifyAllWaiters
public void notifyAllWaiters()
- Notify all of the callers waiting to dequeue.
main
public static void main(java.lang.String[] args)