public class CallSubroutine<I,O> extends CoroutineStep<I,O>
Coroutine
step that executes another coroutine in the context of
the parent routine.Constructor and Description |
---|
CallSubroutine(Coroutine<I,O> rCoroutine)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
static <I,O> CallSubroutine<I,O> |
call(Coroutine<I,O> rCoroutine)
Calls a coroutine as a subroutine of the coroutine this step is added to.
|
protected O |
execute(I rInput,
Continuation<?> rContinuation)
This method must be implemented by subclasses to provide the actual
functionality of this step.
|
void |
runAsync(java.util.concurrent.CompletableFuture<I> fPreviousExecution,
CoroutineStep<O,?> rReturnStep,
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. |
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 static <I,O> CallSubroutine<I,O> call(Coroutine<I,O> rCoroutine)
rCoroutine
- The coroutine to invoke as a subroutinepublic void runAsync(java.util.concurrent.CompletableFuture<I> fPreviousExecution, CoroutineStep<O,?> rReturnStep, 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<I,O>
fPreviousExecution
- The future of the previous code executionrReturnStep
- The next step to execute or NULL for nonerContinuation
- The continuation of the executionprotected O execute(I rInput, Continuation<?> rContinuation)
execute
in class CoroutineStep<I,O>
rInput
- The input valuerContinuation
- The continuation of the execution