((Action) next.q.peek()).execute();
((Action) next.q.peek()).execute();
synchronized public Object restart(Object newState, boolean clearActions){ if(getError() == null) { throw Util.runtimeException("Agent does not need a restart"); } validate(newState); state = newState; if(clearActions) aq.set(ActionQueue.EMPTY); else { boolean restarted = false; ActionQueue prior = null; while(!restarted) { prior = aq.get(); restarted = aq.compareAndSet(prior, new ActionQueue(prior.q, null)); } if(prior.q.count() > 0) ((Action) prior.q.peek()).execute(); } return newState; }
public void run(){ doRun(this); } }
void enqueue(Action action){ boolean queued = false; ActionQueue prior = null; while(!queued) { prior = aq.get(); queued = aq.compareAndSet(prior, new ActionQueue((IPersistentStack)prior.q.cons(action), prior.error)); } if(prior.q.count() == 0 && prior.error == null) action.execute(); }
public Object dispatch(IFn fn, ISeq args, Executor exec) { Throwable error = getError(); if(error != null) { throw Util.runtimeException("Agent is failed, needs restart", error); } Action action = new Action(this, fn, args, exec); dispatchAction(action); return this; }
synchronized public Object restart(Object newState, boolean clearActions){ if(getError() == null) { throw Util.runtimeException("Agent does not need a restart"); } validate(newState); state = newState; if(clearActions) aq.set(ActionQueue.EMPTY); else { boolean restarted = false; ActionQueue prior = null; while(!restarted) { prior = aq.get(); restarted = aq.compareAndSet(prior, new ActionQueue(prior.q, null)); } if(prior.q.count() > 0) ((Action) prior.q.peek()).execute(); } return newState; }
public void run(){ doRun(this); } }
void enqueue(Action action){ boolean queued = false; ActionQueue prior = null; while(!queued) { prior = aq.get(); queued = aq.compareAndSet(prior, new ActionQueue((IPersistentStack)prior.q.cons(action), prior.error)); } if(prior.q.count() == 0 && prior.error == null) action.execute(); }
public Object dispatch(IFn fn, ISeq args, Executor exec) { Throwable error = getError(); if(error != null) { throw Util.runtimeException("Agent is failed, needs restart", error); } Action action = new Action(this, fn, args, exec); dispatchAction(action); return this; }