public class ChannelReceive<T> extends ChannelStep<java.lang.Void,T>
CoroutineScope.getChannel(ChannelId)
.Constructor and Description |
---|
ChannelReceive(java.util.function.Function<Continuation<?>,ChannelId<T>> fGetChannelId)
Creates a new instance that receives from a channel the ID of which is
provided in a state relation.
|
Modifier and Type | Method and Description |
---|---|
protected T |
execute(java.lang.Void rIgnored,
Continuation<?> rContinuation)
This method must be implemented by subclasses to provide the actual
functionality of this step.
|
static <T> ChannelReceive<T> |
receive(ChannelId<T> rId)
Suspends until a value can be received from a certain channel.
|
static <T> ChannelReceive<T> |
receive(java.util.function.Function<Continuation<?>,ChannelId<T>> fGetChannelId)
Suspends until a value can be received from the channel with the ID
provided by the given function.
|
void |
runAsync(java.util.concurrent.CompletableFuture<java.lang.Void> fPreviousExecution,
CoroutineStep<T,?> rNextStep,
Continuation<?> rContinuation)
Runs this execution step asynchronously as a continuation of a previous
code execution in a
CompletableFuture and proceeds to the next
step afterwards. |
getChannel
fail, runBlocking, terminateCoroutine, toString
deleteRelation, get, getRelation, getRelations, notifyRelationListeners, readRelations, relationsEqual, relationsHashCode, relationsString, set, set, transform, writeRelations
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public ChannelReceive(java.util.function.Function<Continuation<?>,ChannelId<T>> fGetChannelId)
fGetChannelId
- The function that will return the channel IDpublic static <T> ChannelReceive<T> receive(ChannelId<T> rId)
rId
- The ID of the channel to receive frompublic static <T> ChannelReceive<T> receive(java.util.function.Function<Continuation<?>,ChannelId<T>> fGetChannelId)
fGetChannelId
- The function that will return the channel IDpublic void runAsync(java.util.concurrent.CompletableFuture<java.lang.Void> fPreviousExecution, CoroutineStep<T,?> rNextStep, Continuation<?> rContinuation)
CompletableFuture
and proceeds to the next
step afterwards.
Subclasses that need to suspend the invocation of the next step until
some condition is met (e.g. sending or receiving data has finished) need
to override this method and create a Suspension
by invoking
Continuation.suspend(CoroutineStep, CoroutineStep)
on the next
step. If the condition that caused the suspension resolves the coroutine
execution can be resumed by calling Suspension.resume(Object)
.
Subclasses that override this method also need to handle errors by
terminating any further execution (i.e. not resuming a suspension if such
exists) and forwarding the causing exception to Continuation.fail(Throwable)
.
runAsync
in class CoroutineStep<java.lang.Void,T>
fPreviousExecution
- The future of the previous code executionrNextStep
- The next step to execute or NULL for nonerContinuation
- The continuation of the executionprotected T execute(java.lang.Void rIgnored, Continuation<?> rContinuation)
execute
in class CoroutineStep<java.lang.Void,T>
rIgnored
- The input valuerContinuation
- The continuation of the execution