T - the type of the input to the operationpublic interface BufferedBlockingConsumer<T> extends BlockingConsumer<T>
BlockingConsumer that retains a maximum number of values in a buffer before sending them to
a delegate consumer. Note that any buffered values may need to be flushed periodically.
This maintains the same order of the values.
| Modifier and Type | Method and Description |
|---|---|
static <T> BufferedBlockingConsumer<T> |
bufferLast(BlockingConsumer<T> delegate)
Get a
BufferedBlockingConsumer that buffers just the last value seen by the consumer. |
default void |
flush()
Flush all of the buffered values to the delegate.
|
void |
flush(Function<T,T> function)
Flush all of the buffered values to the delegate by first running each buffered value through the given function
to generate a new value to be flushed to the delegate consumer.
|
acceptdefault void flush()
throws InterruptedException
InterruptedException - if the thread is interrupted while this consumer is blockedvoid flush(Function<T,T> function) throws InterruptedException
function - the function to apply to the values that are flushedInterruptedException - if the thread is interrupted while this consumer is blockedstatic <T> BufferedBlockingConsumer<T> bufferLast(BlockingConsumer<T> delegate)
BufferedBlockingConsumer that buffers just the last value seen by the consumer.
When another value is then added to the consumer, this buffered consumer will push the prior value into the delegate
and buffer the latest.
The resulting consumer is not threadsafe.
delegate - the delegate to which values should be flushed; may not be nullCopyright © 2017 JBoss by Red Hat. All rights reserved.