Skip to content

Commit 521e077

Browse files
committed
eval on vthread check and memo ver check
1 parent d436c9c commit 521e077

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,15 @@
7373
[workload]
7474
(Executors/newCachedThreadPool (counted-thread-factory (str "async-" (name workload) "-%d") true)))
7575

76-
(defn ensure-clojure-version! [maj min incr]
77-
(let [{:keys [major minor incremental]} *clojure-version*]
78-
(when (neg? (compare [major minor incremental] [maj min incr]))
79-
(throw (ex-info (str "core.async go block expander requires Clojure version ≥"
80-
maj "." min "." incr
81-
" to load")
82-
{:clojure-version *clojure-version*})))))
76+
(def ensure-clojure-version!
77+
(memoize
78+
(fn [maj min incr]
79+
(let [{:keys [major minor incremental]} *clojure-version*]
80+
(when (neg? (compare [major minor incremental] [maj min incr]))
81+
(throw (ex-info (str "core.async go block expander requires Clojure version ≥"
82+
maj "." min "." incr
83+
" to load")
84+
{:clojure-version *clojure-version*})))))))
8385

8486
(def virtual-threads-available?
8587
(try
@@ -105,10 +107,7 @@
105107

106108
(def ^:private virtual-thread?
107109
(if virtual-threads-available?
108-
(let [meth (.getMethod (Class/forName "java.lang.Thread") "isVirtual" (into-array Class []))
109-
vargs (object-array 0)]
110-
(fn [thread]
111-
(.invoke meth thread vargs)))
110+
(eval `(fn [^Thread t#] (~'.isVirtual t#)))
112111
(constantly false)))
113112

114113
(defn in-vthread? []

0 commit comments

Comments
 (0)