summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2008-09-23 15:37:04 +0000
committerRich Hickey <richhickey@gmail.com>2008-09-23 15:37:04 +0000
commit9b9785d3877b10e0ada69eccedd471a17be2a6d2 (patch)
tree1be1e740020f9ee227279ae20afbba250e9f0ba7
parent1c2a26ad5d07f6cc4175f86d9aa95656cf76c6f1 (diff)
added exceptions thrown by watchers to agent's errors, for now
-rw-r--r--src/jvm/clojure/lang/Agent.java21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/jvm/clojure/lang/Agent.java b/src/jvm/clojure/lang/Agent.java
index 2ad5d035..4c0fc715 100644
--- a/src/jvm/clojure/lang/Agent.java
+++ b/src/jvm/clojure/lang/Agent.java
@@ -37,7 +37,7 @@ public static void shutdown(){
pooledExecutor.shutdown();
}
-static class Action implements Callable{
+static class Action implements Runnable{
final Agent agent;
final IFn fn;
final ISeq args;
@@ -53,12 +53,12 @@ static class Action implements Callable{
void execute(){
if(solo)
- soloExecutor.submit(this);
+ soloExecutor.execute(this);
else
- pooledExecutor.submit(this);
+ pooledExecutor.execute(this);
}
- static void doRun(Action action) throws Exception{
+ static void doRun(Action action){
try
{
Var.pushThreadBindings(RT.map(RT.AGENT, action.agent));
@@ -69,6 +69,11 @@ static class Action implements Callable{
try
{
changed = action.agent.setState(action.fn.applyTo(RT.cons(action.agent.state, action.args)));
+ for(Object o : action.agent.watchers.get())
+ {
+ Map.Entry e = (Map.Entry) o;
+ ((IFn) e.getValue()).invoke(e.getKey(), action.agent, RT.box(changed));
+ }
}
catch(Exception e)
{
@@ -79,11 +84,6 @@ static class Action implements Callable{
if(!hadError)
{
- for(Object o : action.agent.watchers.get())
- {
- Map.Entry e = (Map.Entry) o;
- ((IFn) e.getValue()).invoke(e.getKey(), action.agent, RT.box(changed));
- }
for(ISeq s = nested.get().seq(); s != null; s = s.rest())
{
Action a = (Action) s.first();
@@ -111,9 +111,8 @@ static class Action implements Callable{
}
}
- public Object call() throws Exception{
+ public void run(){
doRun(this);
- return this;
}
}