T - the type of object yielded by next()public interface AsyncIterator<T> extends Iterator<T>, Cancellable, Disposable
Iterator that allows for non-blocking iteration over elements.
Calls to next() will not block if onHasNext() has been called
since the last call to next() and the Future returned from
onHasNext() has completed.| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancels any outstanding asynchronous work associated with this
AsyncIterator. |
void |
dispose()
Cancel this
AsyncIterable and dispose of associated resources. |
boolean |
hasNext()
Blocking call to determine if the sequence contains more elements.
|
T |
next()
Returns the next element in the sequence.
|
Future<Boolean> |
onHasNext()
Returns a asynchronous signal for the presence of more elements in the sequence.
|
Future<Boolean> onHasNext()
onHasNext() is ready, the next call to
next() will not block.Future that will be set to true if next()
would return another element without blocking or to false if there are
no more elements in the sequence.boolean hasNext()
onHasNext().get().hasNext in interface Iterator<T>true if there are more elements in the sequence, false
otherwise.onHasNext()T next()
next(), onHasNext() was called and the resulting
Future has completed or the blocking call hasNext() was called
and has returned. It is legal, therefore, to make a call to next() without a
preceding call to
hasNext() or onHasNext(), but that invocation of next()
may block on remote operations.next in interface Iterator<T>NoSuchElementException - if the sequence has been exhausted.void cancel()
AsyncIterator.cancel in interface Cancellablevoid dispose()
AsyncIterable and dispose of associated resources. Equivalent
to calling cancel().dispose in interface Disposable