(Action action)
| 103 | } |
| 104 | |
| 105 | static void doRun(Action action){ |
| 106 | try |
| 107 | { |
| 108 | nested.set(PersistentVector.EMPTY); |
| 109 | |
| 110 | Throwable error = null; |
| 111 | try |
| 112 | { |
| 113 | Object oldval = action.agent.state; |
| 114 | Object newval = action.fn.applyTo(RT.cons(action.agent.state, action.args)); |
| 115 | action.agent.setState(newval); |
| 116 | action.agent.notifyWatches(oldval,newval); |
| 117 | } |
| 118 | catch(Throwable e) |
| 119 | { |
| 120 | error = e; |
| 121 | } |
| 122 | |
| 123 | if(error == null) |
| 124 | { |
| 125 | releasePendingSends(); |
| 126 | } |
| 127 | else |
| 128 | { |
| 129 | nested.set(null); // allow errorHandler to send |
| 130 | if(action.agent.errorHandler != null) |
| 131 | { |
| 132 | try |
| 133 | { |
| 134 | action.agent.errorHandler.invoke(action.agent, error); |
| 135 | } |
| 136 | catch(Throwable e) {} // ignore errorHandler errors |
| 137 | } |
| 138 | if(action.agent.errorMode == CONTINUE) |
| 139 | { |
| 140 | error = null; |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | boolean popped = false; |
| 145 | ActionQueue next = null; |
| 146 | while(!popped) |
| 147 | { |
| 148 | ActionQueue prior = action.agent.aq.get(); |
| 149 | next = new ActionQueue(prior.q.pop(), error); |
| 150 | popped = action.agent.aq.compareAndSet(prior, next); |
| 151 | } |
| 152 | |
| 153 | if(error == null && next.q.count() > 0) |
| 154 | ((Action) next.q.peek()).execute(); |
| 155 | } |
| 156 | finally |
| 157 | { |
| 158 | nested.set(null); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | public void run(){ |
no test coverage detected