@CpsVmThreadOnly("root") public void unexport(BodyReference ref) { assertVmThread(); if (ref==null) return; closures.remove(ref.id); }
@CpsVmThreadOnly("root") public @Nonnull BodyReference export(@Nonnull Closure body) { assertVmThread(); int id = iota++; closures.put(id, body); return new StaticBodyReference(id,body); }
@CpsVmThreadOnly public CpsThread addThread(Continuable program, FlowHead head, ContextVariableSet contextVariables) { assertVmThread(); CpsThread t = new CpsThread(this, iota++, program, head, contextVariables); threads.put(t.id, t); return t; }
/** * Notifies listeners of the new {@link FlowHead}. * * The actual call happens later from a place who owns no lock on any of the CPS objects to avoid deadlock. */ @CpsVmThreadOnly /*package*/ void notifyNewHead(final FlowNode head) { assertVmThread(); execution.notifyListeners(Collections.singletonList(head), true); synchronized (nodesToNotifyLock) { if (nodesToNotify == null) { nodesToNotify = new ArrayList<FlowNode>(); } nodesToNotify.add(head); } runner.execute(new Runnable() { public void run() { List<FlowNode> _nodesToNotify; synchronized (nodesToNotifyLock) { if (nodesToNotify == null) { return; } _nodesToNotify = nodesToNotify; nodesToNotify = null; } execution.notifyListeners(_nodesToNotify, false); } }); }
File tmpFile = File.createTempFile("atomic",null, dir); assertVmThread();