| java.lang.Object org.datashare.FifoQueue
FifoQueue | public class FifoQueue implements Runnable(Code) | | this class is used where we have serializable objects that we want to pass between two
threads in a FIFO/QUEUE fashion, one thread will source the data, and another thread to sink
the data. NOTE!!!! The read() method will block if no object is available to read.
Note that this class can be used to provide the sink thread to feed a consumer by
calling setConsumer() to give it a class/method to call when data is available.
|
Method Summary | |
public void | close() used when the pipe is no longer needed, will cause a blocking read to release
with a null object returned, will also stop the thread if a consumer was set
with setConsumer(). | public Object | read() | public void | reset() | public void | run() used only if a setConsumer() call is made, calls the newFifoDataAvailable method of
the consumer (set in setConsumer) whenever objects are put into the FIFO via the write method. | public void | setConsumer(FifoConsumer consumer) used only if this class is to be used as a Thread to wait for data that will then
be supplied to this consumer as it becomes available, will start thread that supplies
the consumer with objects as they are put into the FIFO with the write method. | public int | size() | public void | write(Object object) |
FifoQueue | public FifoQueue()(Code) | | constructor
|
close | public void close()(Code) | | used when the pipe is no longer needed, will cause a blocking read to release
with a null object returned, will also stop the thread if a consumer was set
with setConsumer().
|
read | public Object read()(Code) | | Returns the oldest object in our FIFO, or blocks until an object is available, may issue null object when FifoQueue is closed
|
reset | public void reset()(Code) | | empties the FIFO
|
run | public void run()(Code) | | used only if a setConsumer() call is made, calls the newFifoDataAvailable method of
the consumer (set in setConsumer) whenever objects are put into the FIFO via the write method.
|
setConsumer | public void setConsumer(FifoConsumer consumer)(Code) | | used only if this class is to be used as a Thread to wait for data that will then
be supplied to this consumer as it becomes available, will start thread that supplies
the consumer with objects as they are put into the FIFO with the write method.
|
size | public int size()(Code) | | used to return the number of objects currently in the buffer
|
write | public void write(Object object)(Code) | | used to put the Objects into a buffer
Parameters: object - Object to be added to our FIFO |
|
|