Class 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
      void runAsync​(java.util.concurrent.CompletableFuture<I> execution, Continuation<?> continuation)
      Executes this subroutine asynchronously in the given future and continuation.
      O runBlocking​(I input, Continuation<?> continuation)
      Executes this subroutine synchronously in the given continuation.
      • Methods inherited from class org.obrel.core.RelatedObject

        deleteRelation, get, getRelation, getRelations, notifyRelationListeners, readRelations, relationsEqual, relationsHashCode, relationsString, set, set, transform, writeRelations
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface de.esoco.lib.property.Fluent

        _with
      • Methods inherited from interface org.obrel.core.FluentRelatable

        with, with, with
      • Methods inherited from interface org.obrel.core.Relatable

        deleteRelation, deleteRelation, deleteRelations, get, getAll, getOption, getRelation, getRelationCount, getRelations, getRelations, hasFlag, hasRelation, hasRelations, init, set, set, set, set, set, setOption, streamRelations, transform
    • 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 subroutine
        returnStep - 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 future
        continuation - 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 value
        continuation - The continuation of the execution
        Returns:
        The result of the execution