Skip to content

Commit 592b809

Browse files
committed
defparkingop will make choice at macroexpansion time rather than deferring to runtime.
1 parent db62cff commit 592b809

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ IOC and vthread code.
165165
(timers/timeout msecs))
166166

167167
(defn- defparkingop-helper [op doc arglist body]
168-
(let [as (mapv #(list 'quote %) arglist)
169-
blockingop (-> op name (str "!") symbol)]
170-
`(def ~(with-meta op {:arglists `(list ~as) :doc doc})
171-
(if dispatch/vthreads-available-and-allowed?
172-
(fn [~'& ~'args]
173-
~(list* apply blockingop '[args]))
174-
(fn ~arglist
175-
~@body)))))
168+
(let [as (mapv #(list 'quote %) arglist)]
169+
(list `def (with-meta op {:arglists `(list ~as) :doc doc})
170+
(if (or dispatch/target-vthreads?
171+
(and dispatch/vthreads-available-and-allowed?
172+
(not clojure.core/*compile-files*)))
173+
(let [blockingop (-> op name (str "!") symbol)]
174+
`(fn [~'& ~'args] ~(list* apply blockingop '[args])))
175+
`(fn ~arglist ~@body)))))
176176

177177
(defmacro defparkingop
178178
"Emits either parking op or reimplement as blocking op when vthreads

0 commit comments

Comments
 (0)