Skip to content

Commit

Permalink
semantic data to thread-call
Browse files Browse the repository at this point in the history
  • Loading branch information
fogus committed Jan 27, 2025
1 parent fdc1964 commit 326dbb5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/clojure/clojure/core/async.clj
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,15 @@ to catch and handle."
"Executes f in another thread, returning immediately to the calling
thread. Returns a channel which will receive the result of calling
f when completed, then close."
([f] (thread-call f mixed-executor))
([f ^ExecutorService exec]
(let [c (chan 1)]
([f] (thread-call f :mixed))
([f exec]
(let [c (chan 1)
^ExecutorService e (case exec
:compute compute-executor
:io io-executor
mixed-executor)]
(let [binds (Var/getThreadBindingFrame)]
(.execute exec
(.execute e
(fn []
(Var/resetThreadBindingFrame binds)
(try
Expand All @@ -496,7 +500,7 @@ to catch and handle."
extended computation (if so, use 'thread' instead). Returns a channel
which will receive the result of the body when completed, then close."
[& body]
`(thread-call (^:once fn* [] ~@body) io-executor))
`(thread-call (^:once fn* [] ~@body) :io))

(defmacro thread
"Executes the body in another thread, returning immediately to the
Expand Down

0 comments on commit 326dbb5

Please sign in to comment.