File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
src/main/clojure/clojure/core Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -515,7 +515,11 @@ use vthreads in io-thread when available
515515 completed"
516516 [& body]
517517 (if (or (dispatch/aot-vthreads? ) (dispatch/runtime-vthreads? ))
518- `(thread-call (^:once fn* [] ~@body) :io )
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 ))
519523 ((find-var 'clojure.core.async.impl.go/go-impl) &env body)))
520524
521525(defonce ^:private thread-macro-executor nil )
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+
8890(defn aot-vthreads? []
8991 (and clojure.core/*compile-files*
9092 (= (vthreads-directive ) " target" )))
9193
92- (defn runtime-vthreads? []
93- (and (not clojure.core/*compile-files*)
94- (not= (vthreads-directive ) " avoid" )
95- @virtual-threads-available?))
94+ (def runtime-vthreads?
95+ (memoize
96+ (fn []
97+ (and (not clojure.core/*compile-files*)
98+ (not= (vthreads-directive ) " avoid" )
99+ @virtual-threads-available?))))
96100
97101(defn- make-io-executor
98102 []
You can’t perform that action at this time.
0 commit comments