public AddError ( |
||
e | The exception to add. | |
return | void |
/// <summary> /// Worker method to execute the action on a thread. /// </summary> /// <param name="state">(not used)</param> /// <remarks>corresponds to doRun in Java version</remarks> void ExecuteAction(object state) { try { Var.pushThreadBindings(RT.map(RT.AGENT, _agent)); Agent.Nested = PersistentVector.EMPTY; bool hadError = false; try { object oldval = _agent.State; object newval = _fn.applyTo(RT.cons(_agent.State, _args)); _agent.SetState(newval); _agent.notifyWatches(oldval, newval); } catch (Exception e) { // TODO: report/callback (Java TODO) _agent.AddError(e); hadError = true; } if (!hadError) { releasePendingSends(); } bool popped = false; IPersistentStack next = null; while (!popped) { IPersistentStack prior = _agent._q.Get(); next = prior.pop(); popped = _agent._q.CompareAndSet(prior, next); } if (next.count() > 0) { ((Action)next.peek()).execute(); } } finally { Nested = null; Var.popThreadBindings(); } }