Skip to content

Commit c91dcb9

Browse files
committed
wip
1 parent 46d1320 commit c91dcb9

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ to catch and handle."
467467
[f workload]
468468
(let [c (chan 1)]
469469
(let [binds (Var/getThreadBindingFrame)]
470-
(dispatch/executor-service-call
470+
(dispatch/exec
471471
(fn []
472472
(Var/resetThreadBindingFrame binds)
473473
(try

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
clojure.core.async.impl.dispatch
1111
(:require [clojure.core.async.impl.protocols :as impl]
1212
[clojure.core.async.impl.exec.threadpool :as tp])
13-
(:import [java.util.concurrent ExecutorService]))
13+
(:import [java.util.concurrent Executors ExecutorService]))
1414

1515
(set! *warn-on-reflection* true)
1616

@@ -38,14 +38,23 @@
3838
(.uncaughtException (Thread/currentThread) ex))
3939
nil)
4040

41+
(defonce ^ExecutorService mixed-executor
42+
(Executors/newCachedThreadPool (conc/counted-thread-factory "async-mixed-%d" true)))
43+
44+
(defonce ^ExecutorService io-executor
45+
(Executors/newCachedThreadPool (conc/counted-thread-factory "async-io-%d" true)))
46+
47+
(defonce ^ExecutorService compute-executor
48+
(Executors/newCachedThreadPool (conc/counted-thread-factory "async-compute-%d" true)))
49+
4150
(defn run
4251
"Runs Runnable r on current thread when :on-caller? meta true, else in a thread pool thread."
4352
[^Runnable r]
4453
(if (-> r meta :on-caller?)
4554
(try (.run r) (catch Throwable t (ex-handler t)))
4655
(impl/exec @executor r)))
4756

48-
(defn executor-service-call
57+
(defn exec
4958
[f exec]
5059
(let [^ExecutorService e (case exec
5160
:compute tp/compute-executor

src/main/clojure/clojure/core/async/impl/exec/threadpool.clj

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
(ns clojure.core.async.impl.exec.threadpool
1010
(:require [clojure.core.async.impl.protocols :as impl]
1111
[clojure.core.async.impl.concurrent :as conc])
12-
(:import [java.util.concurrent Executors ExecutorService]))
12+
(:import [java.util.concurrent Executors]))
1313

1414
(set! *warn-on-reflection* true)
1515

@@ -30,12 +30,3 @@
3030
(reify impl/Executor
3131
(impl/exec [_ r]
3232
(.execute executor-svc ^Runnable r))))))
33-
34-
(defonce ^ExecutorService mixed-executor
35-
(Executors/newCachedThreadPool (conc/counted-thread-factory "async-mixed-%d" true)))
36-
37-
(defonce ^ExecutorService io-executor
38-
(Executors/newCachedThreadPool (conc/counted-thread-factory "async-io-%d" true)))
39-
40-
(defonce ^ExecutorService compute-executor
41-
(Executors/newCachedThreadPool (conc/counted-thread-factory "async-compute-%d" true)))

0 commit comments

Comments
 (0)