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
514
514
Returns a channel which will receive the result of the body when
515
515
completed"
516
516
[& 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)))
524
521
525
522
(defonce ^:private thread-macro-executor nil )
526
523
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
-
90
88
(defn aot-vthreads? []
91
89
(and clojure.core/*compile-files*
92
90
(= (vthreads-directive ) " target" )))
98
96
(not= (vthreads-directive ) " avoid" )
99
97
@virtual-threads-available?))))
100
98
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
+
101
104
(defn- make-io-executor
102
105
[]
103
106
(if (runtime-vthreads? )
You can’t perform that action at this time.
0 commit comments