summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/clj/clojure/core.clj6
-rw-r--r--test/clojure/test_clojure/agents.clj13
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