Package io.servicetalk.concurrent
Interface BlockingIterable.Processor<T>
- Type Parameters:
T- the type of elements returned by theBlockingIterator.
- All Superinterfaces:
AutoCloseable,BlockingIterable<T>,CloseableIterable<T>,Iterable<T>
- Enclosing interface:
- BlockingIterable<T>
A
BlockingIterable that supports to dynamically emitting items using next(Object).
If multiple BlockingIterators are created by this BlockingIterable then an implementation
will choose how to distribute the items emitted from next(Object) to those BlockingIterators.
There is no common guarantee about the nature of that distribution.
Lifetime
There are two aspects of the lifetime of thisProcessor, one from the producer side and one from the
consumer side (BlockingIterator.
Producer Lifetime
A producer MUST invoke eitherclose() (successful termination) or
fail(Throwable) (unsuccessful termination) to correctly terminate the producer side of this
Processor.
Consumer Lifetime
A consumer can prematurely indicate termination by callingBlockingIterator.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().-
Nested Class Summary
Nested classes/interfaces inherited from interface io.servicetalk.concurrent.BlockingIterable
BlockingIterable.Processor<T> -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes thisBlockingIterableand all the current or futureBlockingIterators.voidTerminates thisBlockingIterableand all the current or futureBlockingIterators with a failure.voidEmits the passednextItemfrom theBlockingIteratorwhen called.Methods inherited from interface io.servicetalk.concurrent.BlockingIterable
forEach, forEach, forEach, iterator, spliterator
-
Method Details
-
next
Emits the passednextItemfrom theBlockingIteratorwhen called.- Parameters:
nextItem- to emit from theBlockingIteratorwhen called.- Throws:
Exception- If the item could not be emitted.
-
fail
Terminates thisBlockingIterableand all the current or futureBlockingIterators with a failure.After this method returns, any subsequent calls to
next(Object)MUST throw anException. All current and futureBlockingIterators created by thisBlockingIterableMUST eventually throw anExceptionwhich is the same as passedcauseor wraps the same.- Parameters:
cause- for the failure.- Throws:
Exception- If thisBlockingIterablecan not be terminated with a failure.
-
close
Closes thisBlockingIterableand all the current or futureBlockingIterators.After this method returns, any subsequent calls to
next(Object)MUST throw anException. All current and futureBlockingIterators created by thisBlockingIterableMUST eventually returnfalsefrom the varioushasNextmethods.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception- If closure failed.
-