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 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.
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 TypeMethodDescriptionvoid
close()
Closes thisBlockingIterable
and all the current or futureBlockingIterator
s.void
Terminates thisBlockingIterable
and all the current or futureBlockingIterator
s with a failure.void
Emits the passednextItem
from theBlockingIterator
when called.Methods inherited from interface io.servicetalk.concurrent.BlockingIterable
forEach, forEach, iterator, spliterator
-
Method Details
-
next
Emits the passednextItem
from theBlockingIterator
when called.- Parameters:
nextItem
- to emit from theBlockingIterator
when called.- Throws:
Exception
- If the item could not be emitted.
-
fail
Terminates thisBlockingIterable
and all the current or futureBlockingIterator
s with a failure.After this method returns, any subsequent calls to
next(Object)
MUST throw anException
. All current and futureBlockingIterator
s created by thisBlockingIterable
MUST eventually throw anException
which is the same as passedcause
or wraps the same.- Parameters:
cause
- for the failure.- Throws:
Exception
- If thisBlockingIterable
can not be terminated with a failure.
-
close
Closes thisBlockingIterable
and all the current or futureBlockingIterator
s.After this method returns, any subsequent calls to
next(Object)
MUST throw anException
. All current and futureBlockingIterator
s created by thisBlockingIterable
MUST eventually returnfalse
from the varioushasNext
methods.- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
- If closure failed.
-