Interface BlockingIterable<T>

    • Method Detail

      • forEach

        default void forEach​(java.util.function.Consumer<? super T> action,
                             long timeout,
                             java.util.concurrent.TimeUnit unit)
                      throws java.util.concurrent.TimeoutException
        Mimics the behavior of 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.

        Parameters:
        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.
        Throws:
        java.util.concurrent.TimeoutException - If the total iteration time as determined by BlockingIterator.hasNext(long, TimeUnit) takes longer than the timeout duration.