|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--uk.org.ogsadai.common.CircularBuffer
This is a thread-safe, fixed-sized, circular buffer that can be written to by a producer and read from by a consumer. The producer can close the buffer to indicate that no more blocks will be written.
| Constructor Summary | |
CircularBuffer()
Constructs a circular buffer with the default buffer size. |
|
CircularBuffer(int size)
Constructs a circular buffer with the specified buffer size. |
|
| Method Summary | |
void |
close()
Closes the circular buffer indicating that no more blocks will be written to it. |
java.lang.Object |
read()
Reads an object from the buffer. |
void |
write(java.lang.Object block)
Writes an object to the buffer. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public CircularBuffer()
public CircularBuffer(int size)
size - The number of blocks that the buffer can contain.| Method Detail |
public java.lang.Object read()
throws java.lang.InterruptedException
Object or null if the
buffer is closed.
java.lang.InterruptedException
public void write(java.lang.Object block)
throws java.lang.InterruptedException
block - The block of data.
java.lang.InterruptedExceptionpublic void close()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||