|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--uk.org.ogsadai.engine.SynchronizedGrowablePipe
This is a pipe designed to be shared between exactly two threads. One thread writes and one thread reads. It works by maintaining two discrete buffers, one for each thread. This is done in such a way that the only time synchronization is required is when the buffers are filled and need to be switched. This implementation is thread safe for a single producer and consumer only. More than one of either renders this implementation unsafe. While this class can be used in any situation where one thread is providing and another consuming, within the scope of the execution model this class is very tightly coupled with RunAheadHandler.
| Constructor Summary | |
SynchronizedGrowablePipe()
|
|
| 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. |
java.lang.Object |
next()
Gets the next block of data contained in the block reader. |
void |
put(java.lang.Object block)
Writes the specified block of output data. |
void |
waitForBlock()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public SynchronizedGrowablePipe()
| Method Detail |
public java.lang.Object next()
BlockReader
next in interface BlockReaderObjectBlockReader.next()public void close()
BlockWriterput method
should no longer be used.
close in interface BlockWriterBlockWriter.close()public void put(java.lang.Object block)
BlockWriter
put in interface BlockWriterblock - the Object block to writeBlockWriter.put(Object)public boolean hasNext()
BlockReader
hasNext in interface BlockReaderpublic void waitForBlock()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||