|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.org.ogsadai.engine.SynchronizedPipe
A simple fixed-sized synchronized pipe that uses a circular buffer to store blocks of data. The producer and consumer threads that use the pipe should be distinct.
Field Summary | |
private static java.lang.String |
COPYRIGHT_NOTICE Copyright statement. |
private CircularBuffer |
mBuffer Stores the blocks contained in the pipe. |
private boolean |
mFirstCall Indicates the first time the hasNext method is invoked. |
private java.lang.Object |
mNext The next block to return. |
Constructor Summary | |
SynchronizedPipe(int bufferSize) Constructs a synchronized pipe of the specified fixed size. |
Method Summary | |
void |
close() Closes the block writer to indicate that there are no more blocks are to be written. |
boolean |
hasNext() Indicates whether or not there are any more blocks of data to be read from the block reader. |
boolean |
isOpen() Indicates whether or not the block writer is open for writing via the put method. |
java.lang.Object |
next() Gets the next block of data contained in the block reader. |
private java.lang.Object |
nextBlock() Gets the next block or null if there are no more blocks. |
void |
put(java.lang.Object block) Writes the specified block of output data. |
private void |
readNext() Reads the next block from the circular buffer, blocking until a block becomes available or the pipe is closed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final java.lang.String COPYRIGHT_NOTICE
private final CircularBuffer mBuffer
private java.lang.Object mNext
private boolean mFirstCall
Constructor Detail |
public SynchronizedPipe(int bufferSize)
bufferSize
- The number of blocks that the pipe can store before blocking.Method Detail |
public java.lang.Object next()
BlockReader
next
in interface BlockReader
Object
private java.lang.Object nextBlock()
null
if there are no more blocks.
null
.private void readNext()
public boolean hasNext()
BlockReader
hasNext
in interface BlockReader
public void put(java.lang.Object block)
BlockWriter
put
in interface BlockWriter
block
- the Object
block to writepublic void close()
BlockWriter
put
method should no longer be used.
close
in interface BlockWriter
public boolean isOpen()
BlockWriter
put
method. After the close
method has been invoked this method should return false
.
isOpen
in interface BlockWriter
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |