diff options
author | Rich Hickey <richhickey@gmail.com> | 2008-12-23 19:23:34 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2008-12-23 19:23:34 +0000 |
commit | c29ccf985770f751a41f7e5728938af0316b5dfe (patch) | |
tree | 83d8c0c52c943303f106ca0c1d364eb48c5ce5bf /src/jvm/clojure | |
parent | 7d603560e3a43ba8e787a38312319ff0d6139b54 (diff) |
added release-pending-sends
Diffstat (limited to 'src/jvm/clojure')
-rw-r--r-- | src/jvm/clojure/lang/Agent.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/jvm/clojure/lang/Agent.java b/src/jvm/clojure/lang/Agent.java index 55b97df8..e4500174 100644 --- a/src/jvm/clojure/lang/Agent.java +++ b/src/jvm/clojure/lang/Agent.java @@ -84,11 +84,7 @@ static class Action implements Runnable{ if(!hadError) { - for(ISeq s = nested.get().seq(); s != null; s = s.rest()) - { - Action a = (Action) s.first(); - a.agent.enqueue(a); - } + releasePendingSends(); } boolean popped = false; @@ -232,4 +228,16 @@ public Agent removeWatch(Object watcher) throws Exception{ return this; } +static public int releasePendingSends(){ + IPersistentVector sends = nested.get(); + if(sends == null) + return 0; + for(int i=0;i<sends.count();i++) + { + Action a = (Action) sends.valAt(i); + a.agent.enqueue(a); + } + nested.set(PersistentVector.EMPTY); + return sends.count(); +} } |