T - Type of items stored in this holder.public interface BlockingProcessorSignalsHolder<T>
BlockingIterable.Processor.
consume(ProcessorSignalsConsumer)
and consume(ProcessorSignalsConsumer, long, TimeUnit)) is always done serially however the production
(methods add(Object), terminate(Throwable) and terminate()) may be done concurrently.| Modifier and Type | Method and Description |
|---|---|
void |
add(T item)
Adds an item to this holder.
|
boolean |
consume(ProcessorSignalsConsumer<T> consumer)
Consumes the next item stored in this holder.
|
boolean |
consume(ProcessorSignalsConsumer<T> consumer,
long waitFor,
TimeUnit waitForUnit)
Consumes the next item stored in this holder.
|
void |
terminate()
Terminates this holder, such that no further modifications of this holder are expected.
|
void |
terminate(Throwable cause)
Terminates this holder, such that no further modifications of this holder are expected.
|
void add(@Nullable
T item)
throws InterruptedException
item - to add.InterruptedException - If the add was interrupted.void terminate()
throws InterruptedException
consumptions must first consume all previously added items
and then ProcessorSignalsConsumer.consumeTerminal() consume termination}.InterruptedException - If termination was interrupted.void terminate(Throwable cause)
throws InterruptedException
consumptions must first consume all previously added
items and then ProcessorSignalsConsumer.consumeTerminal() consume termination}.cause - Throwable as a cause for termination.InterruptedException - If termination was interrupted.boolean consume(ProcessorSignalsConsumer<T> consumer) throws InterruptedException
successfully or with an error then consume that
successful or
failed termination.
This method will block till an item or a terminal event is available in the holder.
consumer - ProcessorSignalsConsumer to consume the next item or termination in this holdertrue if any method was called on the passed ProcessorSignalsConsumer.InterruptedException - If the thread was interrupted while waiting for an item or terminal event.boolean consume(ProcessorSignalsConsumer<T> consumer, long waitFor, TimeUnit waitForUnit) throws TimeoutException, InterruptedException
successfully or with an error then consume that
successful or
failed termination.
This method will block till an item or a terminal event is available in the holder or the passed waitFor
duration has elapsed.
consumer - ProcessorSignalsConsumer to consume the next item or termination in this holderwaitFor - Duration to wait for an item or termination to be available.waitForUnit - TimeUnit for waitFor.true if any method was called on the passed ProcessorSignalsConsumer.TimeoutException - If there was no item or termination available in the holder for the passed
waitFor durationInterruptedException - If the thread was interrupted while waiting for an item or terminal event.