summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChouser <chouser@n01se.net>2010-11-07 22:09:38 -0500
committerStuart Halloway <stu@thinkrelevance.com>2010-11-29 20:57:30 -0500
commit7e38388e522b1e09dc02157113174640bb32e6ab (patch)
tree23b38067950bcbad3796fc6eb2a3353acdfcf97c
parent460ba9ba5c6dd4df728316f934a38498da901e8c (diff)
Restore *agent* binding in agent action. CLJ-672
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
-rw-r--r--src/clj/clojure/core.clj6
-rw-r--r--src/jvm/clojure/lang/Agent.java2
-rw-r--r--test/clojure/test_clojure/agents.clj6
3 files changed, 10 insertions, 4 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index ed240193..ec81a5cc 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -1821,7 +1821,8 @@
{:added "1.0"
:static true}
[^clojure.lang.Agent a f & args]
- (. a (dispatch (binding-conveyor-fn f) args false)))
+ (binding [*agent* a]
+ (.dispatch a (binding-conveyor-fn f) args false)))
(defn send-off
"Dispatch a potentially blocking action to an agent. Returns the
@@ -1832,7 +1833,8 @@
{:added "1.0"
:static true}
[^clojure.lang.Agent a f & args]
- (. a (dispatch (binding-conveyor-fn f) args true)))
+ (binding [*agent* a]
+ (.dispatch a (binding-conveyor-fn f) args true)))
(defn release-pending-sends
"Normally, actions sent directly or indirectly during another action
diff --git a/src/jvm/clojure/lang/Agent.java b/src/jvm/clojure/lang/Agent.java
index 0ba7c167..67230bfc 100644
--- a/src/jvm/clojure/lang/Agent.java
+++ b/src/jvm/clojure/lang/Agent.java
@@ -107,7 +107,6 @@ static class Action implements Runnable{
static void doRun(Action action){
try
{
- Var.pushThreadBindings(RT.map(RT.AGENT, action.agent));
nested.set(PersistentVector.EMPTY);
Throwable error = null;
@@ -159,7 +158,6 @@ static class Action implements Runnable{
finally
{
nested.set(null);
- Var.popThreadBindings();
}
}
diff --git a/test/clojure/test_clojure/agents.clj b/test/clojure/test_clojure/agents.clj
index 6dc35790..ae0385ec 100644
--- a/test/clojure/test_clojure/agents.clj
+++ b/test/clojure/test_clojure/agents.clj
@@ -108,6 +108,12 @@
(is (= 10 @agt))
(is (nil? (agent-error agt)))))
+(deftest earmuff-agent-bound
+ (let [a (agent 1)]
+ (send a (fn [_] *agent*))
+ (await a)
+ (is (= a @a))))
+
; http://clojure.org/agents
; agent