File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed
src/main/clojure/clojure/core Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -514,13 +514,10 @@ use vthreads in io-thread when available
514514 Returns a channel which will receive the result of the body when
515515 completed"
516516 [& body]
517- (if (or (dispatch/aot-vthreads? ) (dispatch/runtime-vthreads? ))
518- `(if (and (= dispatch/compiled-vthreads-flag " target" ) (not (dispatch/runtime-vthreads? )))
519- (throw (ex-info " Code compiled to target virtual threads, but is running on a JVM without vthread support."
520- {:compiled-vthreads-flag dispatch/compiled-vthreads-flag
521- :runtime-jvm-version (System/getProperty " java.version" )}))
522- (thread-call (^:once fn* [] ~@body) :io ))
523- ((find-var 'clojure.core.async.impl.go/go-impl) &env body)))
517+ (cond (dispatch/aot-vthreads? ) `(do (dispatch/ensure-runtime-vthreads! )
518+ (thread-call (^:once fn* [] ~@body) :io ))
519+ (dispatch/runtime-vthreads? ) `(thread-call (^:once fn* [] ~@body) :io )
520+ :default ((find-var 'clojure.core.async.impl.go/go-impl) &env body)))
524521
525522(defonce ^:private thread-macro-executor nil )
526523
Original file line number Diff line number Diff line change 8585 []
8686 (System/getProperty " clojure.core.async.vthreads" ))
8787
88- (def compiled-vthreads-flag (vthreads-directive ))
89-
9088(defn aot-vthreads? []
9189 (and clojure.core/*compile-files*
9290 (= (vthreads-directive ) " target" )))
9896 (not= (vthreads-directive ) " avoid" )
9997 @virtual-threads-available?))))
10098
99+ (defn ensure-runtime-vthreads! []
100+ (when (not (runtime-vthreads? ))
101+ (throw (ex-info " Code compiled to target virtual threads, but is running on a JVM without vthread support."
102+ {:runtime-jvm-version (System/getProperty " java.version" )}))))
103+
101104(defn- make-io-executor
102105 []
103106 (if (runtime-vthreads? )
You can’t perform that action at this time.
0 commit comments