T - the type of elements returned by the BlockingIterator.public interface BlockingIterable<T> extends CloseableIterable<T>
Iterable which supports generation of BlockingIterators.
This interface is meant to be the synchronous API equivalent of PublisherSource. Each call to
iterator() is equivalent to calling PublisherSource.subscribe(Subscriber) and typically has the
same characteristics in terms of being able to call the method multiple times and data availability in memory.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
BlockingIterable.Processor<T>
A
BlockingIterable that supports to dynamically emitting items using BlockingIterable.Processor.next(Object). |
| Modifier and Type | Method and Description |
|---|---|
default void |
forEach(java.util.function.Consumer<? super T> action,
java.util.function.LongSupplier timeoutSupplier,
java.util.concurrent.TimeUnit unit)
Mimics the behavior of
Iterable.forEach(Consumer) but uses the timeoutSupplier to determine the timeout
value for interactions with the BlockingIterator. |
default void |
forEach(java.util.function.Consumer<? super T> action,
long timeout,
java.util.concurrent.TimeUnit unit)
Mimics the behavior of
Iterable.forEach(Consumer) but applies a timeout duration for the overall
completion of this method. |
BlockingIterator<T> |
iterator() |
default BlockingSpliterator<T> |
spliterator()
The same behavior as
Iterable.spliterator(), but returns a BlockingSpliterator view. |
BlockingIterator<T> iterator()
iterator in interface CloseableIterable<T>iterator in interface java.lang.Iterable<T>default void forEach(java.util.function.Consumer<? super T> action, java.util.function.LongSupplier timeoutSupplier, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.TimeoutException
Iterable.forEach(Consumer) but uses the timeoutSupplier to determine the timeout
value for interactions with the BlockingIterator.
By default the timeoutSupplier will be used for each interaction with
BlockingIterator.hasNext(long, TimeUnit) and BlockingIterator.next(long, TimeUnit). However
implementations of BlockingIterable may decide to only apply the timeout when they are not be sure if
an interaction with the BlockingIterator will block or not.
action - The action to be performed for each element.timeoutSupplier - A LongSupplier that provides the timeout duration for the next call to
BlockingIterator.hasNext(long, TimeUnit) and BlockingIterator.next(long, TimeUnit). These
methods should be consulted for the meaning of non-positive timeout durations.unit - The units for the duration of time.java.util.concurrent.TimeoutException - If an individual call to BlockingIterator.hasNext(long, TimeUnit) takes
longer than the timeout duration.default void forEach(java.util.function.Consumer<? super T> action, long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.TimeoutException
Iterable.forEach(Consumer) but applies a timeout duration for the overall
completion of this method. The timeout is adjusted for each interaction with the
BlockingIterator which may block.
Note that the timeout duration is an approximation and this duration maybe
exceeded if data is available without blocking.
By default the timeout will be used for each interaction with
BlockingIterator.hasNext(long, TimeUnit) and BlockingIterator.next(long, TimeUnit). However
implementations of BlockingIterable may decide to only apply the timeout when they are not be sure if
an interaction with the BlockingIterator will block or not.
action - The action to be performed for each element.timeout - An approximate total duration for the overall completion of this method. This value is used to
approximate because the actual duration maybe longer if data is available without blocking.unit - The units for the duration of time.java.util.concurrent.TimeoutException - If the total iteration time as determined by
BlockingIterator.hasNext(long, TimeUnit) takes longer than the timeout duration.default BlockingSpliterator<T> spliterator()
Iterable.spliterator(), but returns a BlockingSpliterator view.
Calling BlockingSpliterator.close() may result in closing of the underlying BlockingIterator.
spliterator in interface java.lang.Iterable<T>BlockingSpliterator over the elements described by this
BlockingIterable.