Class CoroutineRunner

java.lang.Object
com.offbynull.coroutines.user.CoroutineRunner
All Implemented Interfaces:
Serializable

public final class CoroutineRunner extends Object implements Serializable
Used to execute a Coroutine. All Coroutines must be executed through this class.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • execute

      public boolean execute()
      Starts/resumes execution of this coroutine. If the coroutine being executed reaches a suspension point (meaning that the method calls Continuation.suspend()), this method will return true. If the coroutine has finished executing, this method will return false.

      Calling this method again after the coroutine has finished executing will restart the coroutine.

      Returns:
      false if execution has completed (the method has return), true if execution was suspended.
      Throws:
      CoroutineException - an exception occurred during execution of this coroutine, the saved execution stack and object state may be out of sync at this point (meaning that unless you know what you're doing, you should not call execute() again)
    • getContext

      public Object getContext()
      Get the context. Accessible via the Continuation object that gets used by this coroutine.
      Returns:
      context context
    • setContext

      public void setContext(Object context)
      Set the context. Accessible via the Continuation object that gets used by this coroutine.
      Parameters:
      context - context
    • getCoroutine

      public Coroutine getCoroutine()
      Get the coroutine assigned to this runner.
      Returns:
      coroutine assigned to this runner
    • getContinuation

      Continuation getContinuation()