public ChannelIterator<E>
Iterator for interface ReceiveChannel. Instances of this interface are not thread-safe and shall not be used
from concurrent coroutines.
interface ReceiveChannel| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
hasNext(kotlin.coroutines.experimental.Continuation<? super java.lang.Boolean> p)
Returns
true if the channel has more elements suspending the caller while this channel
ReceiveChannel.isEmpty or returns false if the channel
ReceiveChannel.isClosedForReceive without cause.
It throws the original SendChannel.close cause exception if the channel has failed. |
java.lang.Object |
next(kotlin.coroutines.experimental.Continuation<? super E> p)
Retrieves and removes the element from this channel suspending the caller while this channel
ReceiveChannel.isEmpty or throws exception ClosedReceiveChannelException if the channel
ReceiveChannel.isClosedForReceive without cause.
It throws the original SendChannel.close cause exception if the channel has failed. |
java.lang.Object hasNext(kotlin.coroutines.experimental.Continuation<? super java.lang.Boolean> p)
Returns true if the channel has more elements suspending the caller while this channel
ReceiveChannel.isEmpty or returns false if the channel
ReceiveChannel.isClosedForReceive without cause.
It throws the original SendChannel.close cause exception if the channel has failed.
This function retrieves and removes the element from this channel for the subsequent invocation
of ChannelIterator.next.
This suspending function is cancellable. If the interface Job of the current coroutine is cancelled or completed while this
function is suspended, this function immediately resumes with CancellationException.
Cancellation of suspended receive is atomic -- when this function throws CancellationException it means that the element was not retrieved from this channel. As a side-effect of atomic cancellation, a thread-bound coroutine (to some UI thread, for example) may continue to execute even after it was cancelled from the same thread in the case when this receive operation was already resumed and the continuation was posted for execution to the thread's queue.
Note, that this function does not check for cancellation when it is not suspended.
Use YieldKt.yield or CoroutineScopeKt.isActive to periodically check for cancellation in tight loops if needed.
java.lang.Object next(kotlin.coroutines.experimental.Continuation<? super E> p)
Retrieves and removes the element from this channel suspending the caller while this channel
ReceiveChannel.isEmpty or throws exception ClosedReceiveChannelException if the channel
ReceiveChannel.isClosedForReceive without cause.
It throws the original SendChannel.close cause exception if the channel has failed.
This suspending function is cancellable. If the interface Job of the current coroutine is cancelled or completed while this
function is suspended, this function immediately resumes with CancellationException.
Cancellation of suspended receive is atomic -- when this function throws CancellationException it means that the element was not retrieved from this channel. As a side-effect of atomic cancellation, a thread-bound coroutine (to some UI thread, for example) may continue to execute even after it was cancelled from the same thread in the case when this receive operation was already resumed and the continuation was posted for execution to the thread's queue.
Note, that this function does not check for cancellation when it is not suspended.
Use YieldKt.yield or CoroutineScopeKt.isActive to periodically check for cancellation in tight loops if needed.