uk.org.ogsadai.engine
Class SynchronizedPipe

java.lang.Object
  |
  +--uk.org.ogsadai.engine.SynchronizedPipe
All Implemented Interfaces:
BlockReader, BlockWriter, Pipe

public class SynchronizedPipe
extends java.lang.Object
implements Pipe

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.

Author:
The OGSA-DAI Project Team

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.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SynchronizedPipe

public SynchronizedPipe(int bufferSize)
Constructs a synchronized pipe of the specified fixed size.

Parameters:
bufferSize - The number of blocks that the pipe can store before blocking.
Method Detail

next

public java.lang.Object next()
Description copied from interface: BlockReader
Gets the next block of data contained in the block reader.

Specified by:
next in interface BlockReader
Returns:
an Object

hasNext

public boolean hasNext()
Description copied from interface: BlockReader
Indicates whether or not there are any more blocks of data to be read from the block reader.

Specified by:
hasNext in interface BlockReader
Returns:
true if there are more blocks to be read or false otherwise

put

public void put(java.lang.Object block)
Description copied from interface: BlockWriter
Writes the specified block of output data.

Specified by:
put in interface BlockWriter
Parameters:
block - the Object block to write

close

public void close()
Description copied from interface: BlockWriter
Closes the block writer to indicate that there are no more blocks are to be written. After close has been called, the put method should no longer be used.

Specified by:
close in interface BlockWriter