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
515
515
completed"
516
516
[& body]
517
517
(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 ))
519
523
((find-var 'clojure.core.async.impl.go/go-impl) &env body)))
520
524
521
525
(defonce ^:private thread-macro-executor nil )
Original file line number Diff line number Diff line change 85
85
[]
86
86
(System/getProperty " clojure.core.async.vthreads" ))
87
87
88
+ (def compiled-vthreads-flag (vthreads-directive ))
89
+
88
90
(defn aot-vthreads? []
89
91
(and clojure.core/*compile-files*
90
92
(= (vthreads-directive ) " target" )))
91
93
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?))))
96
100
97
101
(defn- make-io-executor
98
102
[]
You can’t perform that action at this time.
0 commit comments