Skip to content

Commit 5f6bc42

Browse files
committed
finer grained es-factory control
1 parent 0d03c85 commit 5f6bc42

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,22 @@
8080
(.uncaughtException (Thread/currentThread) ex))
8181
nil)
8282

83-
(def construct-es
84-
(let [esf (System/getProperty "clojure.core.async.esfactory")]
85-
(or
86-
(and esf (requiring-resolve (symbol esf)))
87-
(fn [workload]
88-
(case workload
89-
:compute (Executors/newCachedThreadPool (counted-thread-factory "async-compute-%d" true))
90-
:io (Executors/newCachedThreadPool (counted-thread-factory "async-io-%d" true))
91-
:mixed (Executors/newCachedThreadPool (counted-thread-factory "async-mixed-%d" true))
92-
(throw (IllegalArgumentException. (str "Illegal workload tag " workload))))))))
83+
(defn- sys-prop-call
84+
[prop otherwise]
85+
(let [esf (System/getProperty prop)
86+
esfn (or (and esf (requiring-resolve (symbol esf))) otherwise)]
87+
(esfn)))
88+
89+
(defn construct-es
90+
[workload]
91+
(case workload
92+
:compute (sys-prop-call "clojure.core.async.compute-es-fn"
93+
#(Executors/newCachedThreadPool (counted-thread-factory "async-compute-%d" true)))
94+
:io (sys-prop-call "clojure.core.async.io-es-fn"
95+
#(Executors/newCachedThreadPool (counted-thread-factory "async-io-%d" true)))
96+
:mixed (sys-prop-call "clojure.core.async.mixed-es-fn"
97+
#(Executors/newCachedThreadPool (counted-thread-factory "async-mixed-%d" true)))
98+
(throw (IllegalArgumentException. (str "Illegal workload tag " workload)))))
9399

94100
(defonce ^ExecutorService mixed-executor (construct-es :mixed))
95101

0 commit comments

Comments
 (0)