Skip to content

Commit 5e0a9dc

Browse files
committed
Added dynamic-require helper to provide dyn-load of ioc in macro body.
1 parent de8e606 commit 5e0a9dc

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ IOC and vthread code.
532532
completed"
533533
[& body]
534534
(let [rt-check-step (when clojure.core/*compile-files*
535-
'(dispatch/ensure-runtime-vthreads!))]
535+
`(dispatch/ensure-runtime-vthreads!))]
536536
(if go-becomes-ioc?
537-
(do (dispatch/dynamic-require 'clojure.core.async.impl.go)
537+
(do (clojure.core.async.impl.dispatch/dynamic-require 'clojure.core.async.impl.go)
538538
((find-var 'clojure.core.async.impl.go/go-impl) &env body))
539539
`(do ~rt-check-step
540540
(thread-call (^:once fn* [] ~@body) :io)))))

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@
8888
(defn target-vthreads? []
8989
(= (vthreads-directive) "target"))
9090

91-
(def vthreads-available-and-allowed?
92-
(memoize
93-
(fn []
94-
(and (not= (vthreads-directive) "avoid")
95-
@virtual-threads-available?))))
91+
(defn vthreads-available-and-allowed? []
92+
(and (not= (vthreads-directive) "avoid")
93+
@virtual-threads-available?))
9694

9795
(defn ensure-runtime-vthreads! []
9896
(when (not (vthreads-available-and-allowed?))
@@ -111,10 +109,9 @@
111109
clojure.core/*loaded-libs* ll]
112110
(try
113111
(apply require args)
114-
(catch Exception e
115-
e)))))))
112+
(catch Throwable t t)))))))
116113
(let [res @p]
117-
(if (instance? Exception res)
114+
(if res
118115
(throw res)
119116
res))))
120117

0 commit comments

Comments
 (0)