Skip to content

Commit 953f51a

Browse files
committed
dispatch/in-vthread?
1 parent bd2ba1d commit 953f51a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ IOC and vthread code.
169169
blockingop (-> op name (str "!") symbol)]
170170
`(def ~(with-meta op {:arglists `(list ~as) :doc doc})
171171
(fn [~'& ~'args]
172-
(if (= "VirtualThread" (.getSimpleName (class (Thread/currentThread))))
172+
(if (dispatch/in-vthread?)
173173
~(list* apply blockingop '[args])
174174
(assert nil ~(str op " used not in (go ...) block")))))))
175175

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@
9191
(and virtual-threads-available?
9292
(not= (vthreads-directive) "avoid")))
9393

94+
(defn in-vthread? []
95+
(= "VirtualThread" (.getSimpleName (class (Thread/currentThread)))))
96+
9497
(defn report-vthreads-not-available-error! []
9598
(throw (ex-info "Code compiled to target virtual threads, but is running without vthread support."
9699
{:runtime-jvm-version (System/getProperty "java.version")

0 commit comments

Comments
 (0)