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."
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
Original file line number Diff line number Diff line change 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
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
Original file line number Diff line number Diff line change 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
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 )))
You can’t perform that action at this time.
0 commit comments