T
- the type of elements returned by the BlockingIterator
.public static interface BlockingIterable.Processor<T> extends BlockingIterable<T>, java.lang.AutoCloseable
BlockingIterable
that supports to dynamically emitting items using next(Object)
.
If multiple BlockingIterator
s are created by this BlockingIterable
then an implementation
will choose how to distribute the items emitted from next(Object)
to those BlockingIterator
s.
There is no common guarantee about the nature of that distribution.
Processor
, one from the producer side and one from the
consumer side (BlockingIterator
.
close()
(successful termination) or
fail(Throwable)
(unsuccessful termination) to correctly terminate the producer side of this
Processor
.
BlockingIterator.close()
. However, if a
consumer receives a termination from the producer end (BlockingIterator.hasNext(long, TimeUnit)
returns
false
), then it need not call BlockingIterator.close()
.BlockingIterable.Processor<T>
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this
BlockingIterable and all the current or future BlockingIterator s. |
void |
fail(java.lang.Throwable cause)
Terminates this
BlockingIterable and all the current or future BlockingIterator s with a
failure. |
void |
next(T nextItem)
Emits the passed
nextItem from the BlockingIterator when called. |
forEach, forEach, iterator, spliterator
void next(@Nullable T nextItem) throws java.lang.Exception
nextItem
from the BlockingIterator
when called.nextItem
- to emit from the BlockingIterator
when called.java.lang.Exception
- If the item could not be emitted.void fail(java.lang.Throwable cause) throws java.lang.Exception
BlockingIterable
and all the current or future BlockingIterator
s with a
failure.
After this method returns, any subsequent calls to next(Object)
MUST throw an
Exception
. All current and future BlockingIterator
s created by this BlockingIterable
MUST eventually throw an Exception
which is the same as passed cause
or
wraps the same.
cause
- for the failure.java.lang.Exception
- If this BlockingIterable
can not be terminated with a failure.void close() throws java.lang.Exception
BlockingIterable
and all the current or future BlockingIterator
s.
After this method returns, any subsequent calls to next(Object)
MUST throw an
Exception
. All current and future BlockingIterator
s created by this BlockingIterable
MUST eventually return false
from the various hasNext
methods.
close
in interface java.lang.AutoCloseable
java.lang.Exception
- If closure failed.