Skip to content

Commit 73f1be2

Browse files
committed
Revert "ASYNC-259 Implement go-checking with new executors"
This reverts commit 35b27bd.
1 parent 12c5a3e commit 73f1be2

File tree

2 files changed

+19
-25
lines changed

2 files changed

+19
-25
lines changed

src/main/clojure/clojure/core/async/impl/dispatch.clj

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
(set! *warn-on-reflection* true)
1414

15+
(defonce ^:private in-dispatch (ThreadLocal.))
16+
1517
(defonce executor nil)
1618

1719
(defn counted-thread-factory
@@ -35,18 +37,15 @@
3537
(.setName (format name-format (swap! counter inc)))
3638
(.setDaemon daemon))))))))
3739

38-
;; used only for implementing go-checking
39-
(def ^:private ^:dynamic *in-go-dispatch* false)
40-
4140
(defn in-dispatch-thread?
42-
"Returns true if the current thread is used for go block dispatch"
41+
"Returns true if the current thread is a go block dispatch pool thread"
4342
[]
44-
(boolean *in-go-dispatch*))
43+
(boolean (.get ^ThreadLocal in-dispatch)))
4544

4645
(defn check-blocking-in-dispatch
47-
"If the current thread is being used for go block dispatch, throw an exception"
46+
"If the current thread is a dispatch pool thread, throw an exception"
4847
[]
49-
(when (in-dispatch-thread?)
48+
(when (.get ^ThreadLocal in-dispatch)
5049
(throw (IllegalStateException. "Invalid blocking call in dispatch thread"))))
5150

5251
(defn ex-handler

src/main/clojure/clojure/core/async/impl/go.clj

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,23 +1041,18 @@
10411041
second
10421042
(emit-state-machine num-user-params user-transitions))))
10431043

1044-
(def ^:private go-checking (Boolean/getBoolean "clojure.core.async.go-checking"))
1045-
10461044
(defn go-impl
10471045
[env body]
1048-
(let [crossing-env (zipmap (keys env) (repeatedly gensym))
1049-
run-body `(let [c# (clojure.core.async/chan 1)
1050-
captured-bindings# (Var/getThreadBindingFrame)]
1051-
(dispatch/run
1052-
(^:once fn* []
1053-
(let [~@(mapcat (fn [[l sym]] [sym `(^:once fn* [] ~(vary-meta l dissoc :tag))]) crossing-env)
1054-
f# ~(state-machine
1055-
`(do ~@body) 1 [crossing-env env] rt/async-custom-terminators)
1056-
state# (-> (f#)
1057-
(rt/aset-all! rt/USER-START-IDX c#
1058-
rt/BINDINGS-IDX captured-bindings#))]
1059-
(rt/run-state-machine-wrapped state#))))
1060-
c#)]
1061-
(if go-checking
1062-
(list 'binding ['clojure.core.async.impl.dispatch/*in-go-dispatch* true] run-body)
1063-
run-body)))
1046+
(let [crossing-env (zipmap (keys env) (repeatedly gensym))]
1047+
`(let [c# (clojure.core.async/chan 1)
1048+
captured-bindings# (Var/getThreadBindingFrame)]
1049+
(dispatch/run
1050+
(^:once fn* []
1051+
(let [~@(mapcat (fn [[l sym]] [sym `(^:once fn* [] ~(vary-meta l dissoc :tag))]) crossing-env)
1052+
f# ~(state-machine
1053+
`(do ~@body) 1 [crossing-env env] rt/async-custom-terminators)
1054+
state# (-> (f#)
1055+
(rt/aset-all! rt/USER-START-IDX c#
1056+
rt/BINDINGS-IDX captured-bindings#))]
1057+
(rt/run-state-machine-wrapped state#))))
1058+
c#)))

0 commit comments

Comments
 (0)