cork.util
Class BlockingQueue

java.lang.Object
  |
  +--cork.util.BlockingQueue
All Implemented Interfaces:
Queue

public final class BlockingQueue
extends java.lang.Object
implements Queue

A simple thread-safe blocking FIFO queue.
calls to next(), peek(), skip() will block until there are one or more. The queue is thread-safe so that multiple threads can simultaneously add and remove objects from it.

Version:
0.1 Revision 0

Constructor Summary
BlockingQueue()
          BlockingQueue constructor comment.
 
Method Summary
 void add(java.lang.Object object)
          Adds and object to the queue.
 void clear()
          Clears the queue of all object it is holding.
 void loop()
          Force the pool to allow any listening threads to run their run() loops...
 java.lang.Object next()
          Returns the next object in the queue, removing it in the process.
 java.lang.Object peek()
          Returns the next object in the queue without removing it in the process.
 int size()
          Returns the number of elements currently in the queue.
 void skip()
          Skips the next object in the queue, removing it in the process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockingQueue

public BlockingQueue()
BlockingQueue constructor comment.
Method Detail

add

public void add(java.lang.Object object)
Adds and object to the queue. The order that objects are added is implementation dependant.
Specified by:
add in interface Queue
Returns:
java.lang.Object

loop

public void loop()
Force the pool to allow any listening threads to run their run() loops... this allows the pool to tell the thread its being destroyed. the next call to next() or peek() will return null.

clear

public void clear()
Clears the queue of all object it is holding.
Specified by:
clear in interface Queue

next

public java.lang.Object next()
Returns the next object in the queue, removing it in the process. The order that objects are returned is implementation dependant.
Specified by:
next in interface Queue
Returns:
java.lang.Object
See Also:
Queue.peek()

peek

public java.lang.Object peek()
Returns the next object in the queue without removing it in the process. The order that objects are returned is implementation dependant. For the BLocking Queue, it's FIFO.
Specified by:
peek in interface Queue
Returns:
java.lang.Object
See Also:
Queue.next()

size

public int size()
Returns the number of elements currently in the queue.
Specified by:
size in interface Queue
Returns:
int

skip

public void skip()
Skips the next object in the queue, removing it in the process. The order that objects are skipped is implementation dependant. For the BlockingQueue, the first object will be skipped.
Specified by:
skip in interface Queue
Returns:
java.lang.Object
See Also:
Queue.next()