E- The generic type of the elements in the chunks.
public interface IBlockingBuffer<E> extends IRunnableBuffer<E>
Interface provides an iterator to drain chunks from an
This interface is useful where one (or more) processes will write
asynchronously on the
IBuffer while another drains it via the
iterator(). For better performance in a multi-threaded environment,
each thread is given an
UnsynchronizedArrayBuffer of some capacity.
The threads populate their
UnsynchronizedArrayBuffers in parallel
using non-blocking operations. The
turn are configured to flush chunks of elements onto an either an
IBuffer whose generic type is
E. Each element in
IBuffer is therefore a chunk of elements from one of the
There are two families of synchronized
IBufferthat targets a mutable
IBlockingBufferthat exposes an
IAsynchronousIteratorfor reading chunks of elements.
This design means that blocking operations are restricted to chunk-at-a-time
operations, primarily when an
overflows onto an
<E> and when the
<E> either is flushed onto an
IMutableRelation or drained by an
|Modifier and Type||Method and Description|
This is a NOP since the
Return an iterator reading from the buffer.
abort, add, close, getFuture, isOpen
IBlockingBufferby concurrent processes in which case the order is not predictable without additional synchronization.
iterator()is the only way to consume data written on the buffer.
void setFuture(Future future)
Futurefor the source processing writing on the
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.
Copyright © 2006-2015 SYSTAP, LLC. All Rights Reserved.