File tree Expand file tree Collapse file tree 3 files changed +13
-13
lines changed
src/main/clojure/clojure/core Expand file tree Collapse file tree 3 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -467,7 +467,7 @@ to catch and handle."
467
467
[f workload]
468
468
(let [c (chan 1 )]
469
469
(let [binds (Var/getThreadBindingFrame )]
470
- (dispatch/executor-service-call
470
+ (dispatch/exec
471
471
(fn []
472
472
(Var/resetThreadBindingFrame binds)
473
473
(try
Original file line number Diff line number Diff line change 10
10
clojure.core.async.impl.dispatch
11
11
(:require [clojure.core.async.impl.protocols :as impl]
12
12
[clojure.core.async.impl.exec.threadpool :as tp])
13
- (:import [java.util.concurrent ExecutorService]))
13
+ (:import [java.util.concurrent Executors ExecutorService]))
14
14
15
15
(set! *warn-on-reflection* true )
16
16
38
38
(.uncaughtException (Thread/currentThread ) ex))
39
39
nil )
40
40
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
+
41
50
(defn run
42
51
" Runs Runnable r on current thread when :on-caller? meta true, else in a thread pool thread."
43
52
[^Runnable r]
44
53
(if (-> r meta :on-caller? )
45
54
(try (.run r) (catch Throwable t (ex-handler t)))
46
55
(impl/exec @executor r)))
47
56
48
- (defn executor-service-call
57
+ (defn exec
49
58
[f exec]
50
59
(let [^ExecutorService e (case exec
51
60
:compute tp/compute-executor
Original file line number Diff line number Diff line change 9
9
(ns clojure.core.async.impl.exec.threadpool
10
10
(:require [clojure.core.async.impl.protocols :as impl]
11
11
[clojure.core.async.impl.concurrent :as conc])
12
- (:import [java.util.concurrent Executors ExecutorService ]))
12
+ (:import [java.util.concurrent Executors]))
13
13
14
14
(set! *warn-on-reflection* true )
15
15
30
30
(reify impl/Executor
31
31
(impl/exec [_ r]
32
32
(.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 )))
You can’t perform that action at this time.
0 commit comments