(Object newState, boolean clearActions)
| 205 | } |
| 206 | |
| 207 | synchronized public Object restart(Object newState, boolean clearActions){ |
| 208 | if(getError() == null) |
| 209 | { |
| 210 | throw Util.runtimeException("Agent does not need a restart"); |
| 211 | } |
| 212 | validate(newState); |
| 213 | state = newState; |
| 214 | |
| 215 | if(clearActions) |
| 216 | aq.set(ActionQueue.EMPTY); |
| 217 | else |
| 218 | { |
| 219 | boolean restarted = false; |
| 220 | ActionQueue prior = null; |
| 221 | while(!restarted) |
| 222 | { |
| 223 | prior = aq.get(); |
| 224 | restarted = aq.compareAndSet(prior, new ActionQueue(prior.q, null)); |
| 225 | } |
| 226 | |
| 227 | if(prior.q.count() > 0) |
| 228 | ((Action) prior.q.peek()).execute(); |
| 229 | } |
| 230 | |
| 231 | return newState; |
| 232 | } |
| 233 | |
| 234 | public Object dispatch(IFn fn, ISeq args, Executor exec) { |
| 235 | Throwable error = getError(); |
nothing calls this directly
no test coverage detected