Package de.esoco.coroutine
Class Subroutine<I,T,O>
- java.lang.Object
-
- org.obrel.core.RelatedObject
-
- de.esoco.coroutine.Coroutine<I,O>
-
- de.esoco.coroutine.Subroutine<I,T,O>
-
- All Implemented Interfaces:
de.esoco.lib.property.Fluent<Coroutine<I,O>>,org.obrel.core.FluentRelatable<Coroutine<I,O>>,org.obrel.core.Relatable
public class Subroutine<I,T,O> extends Coroutine<I,O>
A coroutine subclass for the invocation of coroutines as subroutines in the context of another execution.
-
-
Constructor Summary
Constructors Constructor Description Subroutine(Coroutine<I,T> coroutine, CoroutineStep<T,O> returnStep)Creates a new instance that invokes the code of another coroutine as a subroutine and then returns the control flow to a step in the invoking subroutine.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidrunAsync(java.util.concurrent.CompletableFuture<I> execution, Continuation<?> continuation)Executes this subroutine asynchronously in the given future and continuation.OrunBlocking(I input, Continuation<?> continuation)Executes this subroutine synchronously in the given continuation.-
Methods inherited from class de.esoco.coroutine.Coroutine
first, first, runAsync, runBlocking, then, then, toString
-
Methods inherited from class org.obrel.core.RelatedObject
deleteRelation, get, getRelation, getRelations, notifyRelationListeners, readRelations, relationsEqual, relationsHashCode, relationsString, set, set, transform, writeRelations
-
-
-
-
Constructor Detail
-
Subroutine
public Subroutine(Coroutine<I,T> coroutine, CoroutineStep<T,O> returnStep)
Creates a new instance that invokes the code of another coroutine as a subroutine and then returns the control flow to a step in the invoking subroutine. The code of the original coroutine will be copied into this instance, not referenced directly.- Parameters:
coroutine- The coroutine to invoke as a subroutinereturnStep- The step to return to after the subroutine execution
-
-
Method Detail
-
runAsync
public void runAsync(java.util.concurrent.CompletableFuture<I> execution, Continuation<?> continuation)
Executes this subroutine asynchronously in the given future and continuation.- Parameters:
execution- The execution futurecontinuation- The continuation of the execution
-
runBlocking
public O runBlocking(I input, Continuation<?> continuation)
Executes this subroutine synchronously in the given continuation.- Parameters:
input- The input valuecontinuation- The continuation of the execution- Returns:
- The result of the execution
-
-