Class PipelinedBlockingQueue

  extended by com.flat502.rox.utils.PipelinedBlockingQueue

public class PipelinedBlockingQueue
extends java.lang.Object

This class provides a pipelined implementation of the core functionality of Java 1.5's BlockingQueue interface.

Elements are enqueued along with the "origin". Pipelining happens within the context of each origin. Simply put, a thread calling take() will never dequeue an item that shares an origin with another item that was dequeued by a second thread that has not returned to the queue.

Constructor Summary
Method Summary
 void add(java.lang.Object element, java.lang.Object origin)
          Adds the specified element to this queue
 java.lang.Object take()
          Retrieves and removes the free element on this queue.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public PipelinedBlockingQueue()
Method Detail


public void add(java.lang.Object element,
                java.lang.Object origin)
Adds the specified element to this queue

element - The element to enqueue
origin - The origin associated with this element.
java.lang.NullPointerException - if the specified element is null


public java.lang.Object take()
                      throws java.lang.InterruptedException
Retrieves and removes the free element on this queue.

An element is considered free if the origin it is associated with is not shared by another element that was previously dequeued by a thread that has not yet "returned" to this queue

the first free element on this queue
java.lang.InterruptedException - if interrupted while waiting.