Skip to content

Commit 4b8e4b9

Browse files
committed
Added executors, renamed
1 parent 4f03e00 commit 4b8e4b9

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,17 +462,20 @@ to catch and handle."
462462
[& body]
463463
(#'clojure.core.async.impl.go/go-impl &env body))
464464

465-
(defonce ^:private ^Executor thread-macro-executor
466-
(Executors/newCachedThreadPool (conc/counted-thread-factory "async-thread-%d" true)))
465+
(defonce ^ExecutorService mixed-executor
466+
(Executors/newCachedThreadPool (conc/counted-thread-factory "async-mixed-thread-%d" true)))
467467

468-
(defonce ^:private ^ExecutorService io-thread-exec
468+
(defonce ^ExecutorService io-executor
469469
(Executors/newCachedThreadPool (conc/counted-thread-factory "async-io-thread-%d" true)))
470470

471+
(defonce ^ExecutorService compute-executor
472+
(Executors/newFixedThreadPool 8 (conc/counted-thread-factory "async-compute-thread-%d" true)))
473+
471474
(defn thread-call
472475
"Executes f in another thread, returning immediately to the calling
473476
thread. Returns a channel which will receive the result of calling
474477
f when completed, then close."
475-
([f] (thread-call f thread-macro-executor))
478+
([f] (thread-call f mixed-executor))
476479
([f ^ExecutorService exec]
477480
(let [c (chan 1)]
478481
(let [binds (Var/getThreadBindingFrame)]
@@ -493,7 +496,7 @@ to catch and handle."
493496
extended computation (if so, use 'thread' instead). Returns a channel
494497
which will receive the result of the body when completed, then close."
495498
[& body]
496-
`(thread-call (^:once fn* [] ~@body) @#'io-thread-exec))
499+
`(thread-call (^:once fn* [] ~@body) io-executor))
497500

498501
(defmacro thread
499502
"Executes the body in another thread, returning immediately to the

0 commit comments

Comments
 (0)