T - the type of object yielded by next()public interface AsyncIterator<T>
extends java.util.Iterator<T>
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 CompletableFuture returned from
onHasNext() has completed.| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancels any outstanding asynchronous work associated with this
AsyncIterator. |
boolean |
hasNext()
Blocking call to determine if the sequence contains more elements.
|
T |
next()
Returns the next element in the sequence.
|
java.util.concurrent.CompletableFuture<java.lang.Boolean> |
onHasNext()
Returns a asynchronous signal for the presence of more elements in the sequence.
|
java.util.concurrent.CompletableFuture<java.lang.Boolean> onHasNext()
onHasNext() is ready, the next call to
next() will not block.CompletableFuture 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 java.util.Iterator<T>true if there are more elements in the sequence, false
otherwise.onHasNext()T next()
next(), onHasNext() was called and the resulting
CompletableFuture 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 java.util.Iterator<T>java.util.NoSuchElementException - if the sequence has been exhausted.void cancel()
AsyncIterator.