Skip to content

Commit 326dbb5

Browse files
committed
semantic data to thread-call
1 parent fdc1964 commit 326dbb5

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,15 @@ to catch and handle."
475475
"Executes f in another thread, returning immediately to the calling
476476
thread. Returns a channel which will receive the result of calling
477477
f when completed, then close."
478-
([f] (thread-call f mixed-executor))
479-
([f ^ExecutorService exec]
480-
(let [c (chan 1)]
478+
([f] (thread-call f :mixed))
479+
([f exec]
480+
(let [c (chan 1)
481+
^ExecutorService e (case exec
482+
:compute compute-executor
483+
:io io-executor
484+
mixed-executor)]
481485
(let [binds (Var/getThreadBindingFrame)]
482-
(.execute exec
486+
(.execute e
483487
(fn []
484488
(Var/resetThreadBindingFrame binds)
485489
(try
@@ -496,7 +500,7 @@ to catch and handle."
496500
extended computation (if so, use 'thread' instead). Returns a channel
497501
which will receive the result of the body when completed, then close."
498502
[& body]
499-
`(thread-call (^:once fn* [] ~@body) io-executor))
503+
`(thread-call (^:once fn* [] ~@body) :io))
500504

501505
(defmacro thread
502506
"Executes the body in another thread, returning immediately to the

0 commit comments

Comments
 (0)