diff options
author | Stuart Halloway <stu@thinkrelevance.com> | 2010-11-29 17:42:36 -0500 |
---|---|---|
committer | Stuart Halloway <stu@thinkrelevance.com> | 2010-11-29 20:57:30 -0500 |
commit | e742a064b0097d16b336bb719eab488f3e5b17ed (patch) | |
tree | 1098acb03c702958ce6d9fc227b224e8684b4c1a | |
parent | 7e38388e522b1e09dc02157113174640bb32e6ab (diff) |
#672: limit binding to just conveyor-fn, add regression test for "Pop without matching push" symptom
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
-rw-r--r-- | src/clj/clojure/core.clj | 6 | ||||
-rw-r--r-- | test/clojure/test_clojure/agents.clj | 13 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index ec81a5cc..f5e18bb6 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -1821,8 +1821,7 @@ {:added "1.0" :static true} [^clojure.lang.Agent a f & args] - (binding [*agent* a] - (.dispatch a (binding-conveyor-fn f) args false))) + (.dispatch a (binding [*agent* a] (binding-conveyor-fn f)) args false)) (defn send-off "Dispatch a potentially blocking action to an agent. Returns the @@ -1833,8 +1832,7 @@ {:added "1.0" :static true} [^clojure.lang.Agent a f & args] - (binding [*agent* a] - (.dispatch a (binding-conveyor-fn f) args true))) + (.dispatch a (binding [*agent* a] (binding-conveyor-fn f)) args true)) (defn release-pending-sends "Normally, actions sent directly or indirectly during another action diff --git a/test/clojure/test_clojure/agents.clj b/test/clojure/test_clojure/agents.clj index ae0385ec..c0dcfd4f 100644 --- a/test/clojure/test_clojure/agents.clj +++ b/test/clojure/test_clojure/agents.clj @@ -114,6 +114,19 @@ (await a) (is (= a @a)))) +(def ^:dynamic *bind-me* :root-binding) + +(deftest thread-conveyance-to-agents + (let [a (agent nil)] + (doto (Thread. + (fn [] + (binding [*bind-me* :thread-binding] + (send a (constantly *bind-me*))) + (await a))) + (.start) + (.join)) + (is (= @a :thread-binding)))) + ; http://clojure.org/agents ; agent |