File tree 1 file changed +14
-13
lines changed
src/main/clojure/clojure/core/async/impl
1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change 80
80
(.uncaughtException (Thread/currentThread ) ex))
81
81
nil )
82
82
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 )))
83
+ (def ^:private workflow->es-factory-props
84
+ {:compute {:sys-prop " clojure.core.async.compute-es-fn"
85
+ :default #(Executors/newCachedThreadPool (counted-thread-factory " async-compute-%d" true ))}
86
+ :io {:sys-prop " clojure.core.async.io-es-fn"
87
+ :default #(Executors/newCachedThreadPool (counted-thread-factory " async-io-%d" true ))}
88
+ :mixed {:sys-prop " clojure.core.async.mixed-es-fn"
89
+ :default #(Executors/newCachedThreadPool (counted-thread-factory " async-mixed-%d" true ))}})
88
90
89
91
(defn construct-es
90
92
[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)))))
93
+ (let [{:keys [sys-prop default ]} (workflow->es-factory-props workload)
94
+ es-fn (or (when-let [esf (and sys-prop (System/getProperty sys-prop))]
95
+ (requiring-resolve (symbol esf)))
96
+ default )]
97
+ (if es-fn
98
+ (es-fn )
99
+ (throw (IllegalArgumentException. (str " Illegal workload tag " workload))))))
99
100
100
101
(defonce ^ExecutorService mixed-executor (construct-es :mixed ))
101
102
You can’t perform that action at this time.
0 commit comments