public bool Evaluate(IntercalThreadProc proc, int label) { var frame = new ExecutionFrame(this, proc, label); lock (SyncLock) { NextingStack.Push(frame); } bool result = frame.Start(); return(result); }
public void Run(IntercalThreadProc proc) { StartProc sp = Evaluate; sp.BeginInvoke(proc, 0, ar => sp.EndInvoke(ar), null); lock (SyncLock) { while (!Done) { Monitor.Wait(SyncLock); } } if (CurrentException != null) { throw CurrentException; } }
public bool Start() { //Note that the only reason we need to spin up a new thread //is the lurking possiblity of FORGET. If we could guarantee that //the function referenced by this.Proc never does a FORGET then //we could just make a direct function call. var myThread = new IntercalThreadProc(InternalThreadProc); myThread.BeginInvoke(this, ar => myThread.EndInvoke(ar), null); lock (SyncLock) { while (!Complete) { Monitor.Wait(SyncLock); } } return(Result); }
public ExecutionFrame(ExecutionContext context, IntercalThreadProc proc, int label) { ExecutionContext = context; Proc = proc; Label = label; }