Search in sources :

Example 1 with Env

use of com.cloudbees.groovy.cps.Env in project groovy-cps by cloudbees.

the class CpsClosureDef method invoke.

@Override
Next invoke(Env caller, SourceLocation loc, Object receiver, List<?> args, Continuation k) {
    Env e = new ClosureCallEnv(caller, k, loc, capture, self);
    assignArguments(args, e);
    return new Next(body, e, k);
}
Also used : Next(com.cloudbees.groovy.cps.Next) Env(com.cloudbees.groovy.cps.Env)

Example 2 with Env

use of com.cloudbees.groovy.cps.Env in project workflow-cps-plugin by jenkinsci.

the class CpsFlowExecution method start.

@Override
public void start() throws IOException {
    final CpsScript s = parseScript();
    scriptClass = s.getClass();
    s.$initialize();
    final FlowHead h = new FlowHead(this);
    synchronized (this) {
        heads.put(h.getId(), h);
    }
    h.newStartNode(new FlowStartNode(this, iotaStr()));
    final CpsThreadGroup g = new CpsThreadGroup(this);
    g.register(s);
    final SettableFuture<CpsThreadGroup> f = SettableFuture.create();
    programPromise = f;
    // Ensures we've saves the WorkFlowRun at least once with initial state
    saveOwner();
    g.runner.submit(new Runnable() {

        @Override
        public void run() {
            CpsThread t = g.addThread(new Continuable(s, createInitialEnv()), h, null);
            t.resume(new Outcome(null, null));
            f.set(g);
        }

        /**
         * Environment to start executing the script in.
         * During sandbox execution, we need to call sandbox interceptor while executing asynchronous code.
         */
        private Env createInitialEnv() {
            return Envs.empty(isSandbox() ? new SandboxInvoker() : new DefaultInvoker());
        }
    });
}
Also used : FlowStartNode(org.jenkinsci.plugins.workflow.graph.FlowStartNode) DefaultInvoker(com.cloudbees.groovy.cps.sandbox.DefaultInvoker) Env(com.cloudbees.groovy.cps.Env) SandboxInvoker(com.cloudbees.groovy.cps.sandbox.SandboxInvoker) Outcome(com.cloudbees.groovy.cps.Outcome) Continuable(com.cloudbees.groovy.cps.Continuable)

Example 3 with Env

use of com.cloudbees.groovy.cps.Env in project groovy-cps by cloudbees.

the class CpsFunction method invoke.

public Next invoke(Env caller, SourceLocation loc, Object receiver, List<?> args, Continuation k) {
    Env e = new FunctionCallEnv(caller, k, loc, receiver);
    assignArguments(args, e);
    return new Next(body, e, k);
}
Also used : Next(com.cloudbees.groovy.cps.Next) Env(com.cloudbees.groovy.cps.Env)

Aggregations

Env (com.cloudbees.groovy.cps.Env)3 Next (com.cloudbees.groovy.cps.Next)2 Continuable (com.cloudbees.groovy.cps.Continuable)1 Outcome (com.cloudbees.groovy.cps.Outcome)1 DefaultInvoker (com.cloudbees.groovy.cps.sandbox.DefaultInvoker)1 SandboxInvoker (com.cloudbees.groovy.cps.sandbox.SandboxInvoker)1 FlowStartNode (org.jenkinsci.plugins.workflow.graph.FlowStartNode)1