File tree Expand file tree Collapse file tree 4 files changed +31
-22
lines changed
src/main/clojure/clojure/core/async/impl Expand file tree Collapse file tree 4 files changed +31
-22
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,8 @@ Copyright © Rich Hickey and contributors
6565
6666## Changelog
6767
68+ * Release 1.8.726-beta3 on 2025.03.31
69+ * [ ASYNC-259] ( https://clojure.atlassian.net/browse/ASYNC-259 ) (CLJ) Update ` clojure.core.async.go-checking ` with new executor pools
6870* Release 1.8.718-beta2 on 2025.03.10
6971 * [ ASYNC-259] ( https://clojure.atlassian.net/browse/ASYNC-259 ) (CLJ) Implement ` clojure.core.async.go-checking ` with new executor pools
7072 * [ ASYNC-260] ( https://clojure.atlassian.net/browse/ASYNC-260 ) (CLJ) Remove now unused property ` clojure.core.async.pool-size `
Original file line number Diff line number Diff line change 1- 1.8.GENERATED_VERSION-beta2
1+ 1.8.GENERATED_VERSION-beta3
Original file line number Diff line number Diff line change 3535 (.setName (format name-format (swap! counter inc)))
3636 (.setDaemon daemon))))))))
3737
38- ; ; used only for implementing go-checking
39- (def ^:private ^:dynamic *in-go-dispatch* false )
38+ ; ; go blocking checking
39+
40+ (defonce in-go-dispatch (ThreadLocal. ))
41+
42+ (defmacro with-dispatch-thread-marking
43+ [& body]
44+ (if (Boolean/getBoolean " clojure.core.async.go-checking" )
45+ `(try
46+ (.set in-go-dispatch true )
47+ ~@body
48+ (finally
49+ (.set in-go-dispatch false )))
50+ `(do ~@body)))
4051
4152(defn in-dispatch-thread?
4253 " Returns true if the current thread is used for go block dispatch"
4354 []
44- (boolean * in-go-dispatch* ))
55+ (boolean ( .get ^ThreadLocal in-go-dispatch) ))
4556
4657(defn check-blocking-in-dispatch
4758 " If the current thread is being used for go block dispatch, throw an exception"
Original file line number Diff line number Diff line change 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+ (dispatch/with-dispatch-thread-marking
1052+ (let [~@(mapcat (fn [[l sym]] [sym `(^:once fn* [] ~(vary-meta l dissoc :tag ))]) crossing-env)
1053+ f# ~(state-machine
1054+ `(do ~@body) 1 [crossing-env env] rt/async-custom-terminators)
1055+ state# (-> (f# )
1056+ (rt/aset-all! rt/USER-START-IDX c#
1057+ rt/BINDINGS-IDX captured-bindings#))]
1058+ (rt/run-state-machine-wrapped state#)))))
1059+ c#)))
You can’t perform that action at this time.
0 commit comments