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.
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. |
void |
close(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.
|
acceptvoid close(Function<T,T> function) throws InterruptedException
BlockingConsumer.accept(Object) may not be called after this method has been called.
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 threadsafe.
delegate - the delegate to which values should be flushed; may not be nullCopyright © 2021 JBoss by Red Hat. All rights reserved.