Package io.servicetalk.concurrent
Interface BlockingIterable.Processor<T>
-
- Type Parameters:
T- the type of elements returned by theBlockingIterator.
- All Superinterfaces:
java.lang.AutoCloseable,BlockingIterable<T>,CloseableIterable<T>,java.lang.Iterable<T>
- Enclosing interface:
- BlockingIterable<T>
public static interface BlockingIterable.Processor<T> extends BlockingIterable<T>, java.lang.AutoCloseable
ABlockingIterablethat supports to dynamically emitting items usingnext(Object).If multiple
BlockingIterators are created by thisBlockingIterablethen an implementation will choose how to distribute the items emitted fromnext(Object)to thoseBlockingIterators. 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) orfail(Throwable)(unsuccessful termination) to correctly terminate the producer side of thisProcessor.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)returnsfalse), then it need not callBlockingIterator.close().
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.servicetalk.concurrent.BlockingIterable
BlockingIterable.Processor<T>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Closes thisBlockingIterableand all the current or futureBlockingIterators.voidfail(java.lang.Throwable cause)Terminates thisBlockingIterableand all the current or futureBlockingIterators with a failure.voidnext(T nextItem)Emits the passednextItemfrom theBlockingIteratorwhen called.-
Methods inherited from interface io.servicetalk.concurrent.BlockingIterable
forEach, forEach, iterator, spliterator
-
-
-
-
Method Detail
-
next
void next(@Nullable T nextItem) throws java.lang.ExceptionEmits the passednextItemfrom theBlockingIteratorwhen called.- Parameters:
nextItem- to emit from theBlockingIteratorwhen called.- Throws:
java.lang.Exception- If the item could not be emitted.
-
fail
void fail(java.lang.Throwable cause) throws java.lang.Exception
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:
java.lang.Exception- If thisBlockingIterablecan not be terminated with a failure.
-
close
void close() throws java.lang.ExceptionCloses 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 interfacejava.lang.AutoCloseable- Throws:
java.lang.Exception- If closure failed.
-
-