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);
}
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());
}
});
}
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);
}
Aggregations