public class DelegateBuffer<E> extends Object implements IBlockingBuffer<E>
close()
method.Constructor and Description |
---|
DelegateBuffer(IBlockingBuffer<E> delegate) |
Modifier and Type | Method and Description |
---|---|
void |
abort(Throwable cause)
Signal abnormal termination of the process writing on the buffer.
|
void |
add(E e)
Add an element to the buffer.
|
void |
close()
Signal that no more data will be written on this buffer (this is required
in order for the iterator to know when no more data will be made
available).
|
long |
flush()
This is a NOP since the
IBlockingBuffer.iterator() is the only way to consume
data written on the buffer. |
Future |
getFuture()
The
Future for the worker task. |
boolean |
isEmpty()
True iff there are no elements in the buffer.
|
boolean |
isOpen()
Return
true if the buffer is open. |
IAsynchronousIterator<E> |
iterator()
Return an iterator reading from the buffer.
|
void |
reset()
Reset the state of the buffer, including the counter whose value is
reported by
IBuffer.flush() . |
void |
setFuture(Future future)
Set the
Future for the source processing writing on the
IBlockingBuffer (the producer). |
int |
size()
The #of elements currently in the buffer.
|
public DelegateBuffer(IBlockingBuffer<E> delegate)
public void add(E e)
IRunnableBuffer
Note: This method is constrained to throw the specified exception if the
buffer has been IRunnableBuffer.close()
d.
public int size()
IBuffer
public boolean isEmpty()
IBuffer
public boolean isOpen()
IRunnableBuffer
true
if the buffer is open.isOpen
in interface IRunnableBuffer<E>
public void close()
IRunnableBuffer
close
in interface IRunnableBuffer<E>
public void abort(Throwable cause)
IRunnableBuffer
abort
in interface IRunnableBuffer<E>
cause
- The exception thrown by the processing writing on the buffer.public void reset()
IBuffer
IBuffer.flush()
. Any data in the buffer will be discarded.public Future getFuture()
IRunnableBuffer
Future
for the worker task.getFuture
in interface IRunnableBuffer<E>
Future
-or- null
if no Future
has been set.public IAsynchronousIterator<E> iterator()
IBlockingBuffer
IBlockingBuffer
by concurrent
processes in which case the order is not predictable without additional
synchronization.iterator
in interface IBlockingBuffer<E>
public long flush()
IBlockingBuffer
IBlockingBuffer.iterator()
is the only way to consume
data written on the buffer.public void setFuture(Future future)
IBlockingBuffer
Future
for the source processing writing on the
IBlockingBuffer
(the producer).
Note: You should always wrap the task as a FutureTask
and set the
Future
on the IBlockingBuffer
before you start the
consumer. This ensures that the producer will be cancelled if the
consumer is interrupted.
setFuture
in interface IBlockingBuffer<E>
future
- The Future
.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.