net.metanotion.util
Class ObjectPipe<I>

java.lang.Object
  extended by net.metanotion.util.ObjectPipe<I>

public final class ObjectPipe<I>
extends java.lang.Object

A "stream" view of java.util.concurrent.*Queue's. This provides a pipe metaphor, the InPipe is an ObjectInputStream which reads objects written to the OutPipe, which is an ObjectOutputStream. The underlying ObjectPipe uses the java.util.concurrent Queue implementations to provide various blocking semantics and memory bounds.


Field Summary
protected  boolean closed
           
protected  java.util.concurrent.BlockingQueue q
           
 
Constructor Summary
ObjectPipe(int capacity)
          Create an object pipe.
 
Method Summary
 ObjectInputStream<I> getInput()
          Return the reader side of the pipe.
 ObjectOutputStream<I> getOutput()
          Return the writer side of the pipe.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

closed

protected boolean closed

q

protected final java.util.concurrent.BlockingQueue q
Constructor Detail

ObjectPipe

public ObjectPipe(int capacity)
Create an object pipe.

Parameters:
capacity - If capacity is -1, queue will use a linked list(unbounded size), 0 will use a synchronous queue, and > 0 will bound the size of the queue.
Method Detail

getOutput

public ObjectOutputStream<I> getOutput()
Return the writer side of the pipe.

Returns:
Stream to write objects in to the pipe.

getInput

public ObjectInputStream<I> getInput()
Return the reader side of the pipe.

Returns:
Stream to read objects from the pipe.