Class Next

java.lang.Object
com.cloudbees.groovy.cps.Next
All Implemented Interfaces:
Continuation, Serializable

public final class Next extends Object implements Serializable, Continuation
Remaining computation to execute. To work around the lack of tail-call optimization. The remaining computation is either to execute f under {#link #e} and pass the result to k immediately, or to suspend execution by yielding yield, and when the execution is resumed, continue by passing the resume value to k (or throw the resume value to the catch handler as specified by e.)
Author:
Kohsuke Kawaguchi
See Also:
  • Field Details

    • f

      public final Block f
    • e

      public final Env e
    • k

      public final Continuation k
    • yield

      public final Outcome yield
      If the program getting executed wants to yield a value and suspend its execution, this value is set to non-null. This field and f is mutually exclusive.
  • Constructor Details

  • Method Details

    • run

      public Next run()
      Resumes the execution of this program state, until it yields a value or finishes computation.
    • run

      public Outcome run(int max)
      for testing only
    • step

      public Next step()
      Executes one step
    • yield

      public static Next yield(Object v, Env e, Continuation k)
      Creates a Next object that causes the interpreter loop to exit with the specified value, then optionally allow the interpreter to resume with the specified Continuation.
    • yield0

      public static Next yield0(Outcome v, Continuable c)
      Creates a Next object that causes the interpreter loop to exit with the specified value, then optionally allow the interpreter to resume to the continuation represented by Continuable.
    • go0

      public static Next go0(Outcome v, Continuable c)
      Crestes a Next object that causes the interpreter loop to keep evaluating the continuation represented by Continuable by passing the outcome (or throwing it).
    • terminate

      public static Next terminate(Object v)
      Creates a Next object that terminates the computation and either returns a value.
    • unhandledException

      public static Next unhandledException(Throwable t)
      Creates a Next object that terminates the computation by throwing an exception.
    • terminate0

      public static Next terminate0(Outcome v)
      Creates a Next object that terminates the computation and either returns a value or throw an exception.
    • receive

      public Next receive(Object unused)
      As a Continuation, just ignore the argument.
      Specified by:
      receive in interface Continuation