Skip to content

Commit e817b12

Browse files
committed
moving flow to Executor
1 parent 6da0ec7 commit e817b12

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@
9898
async/sliding-buffer of size 100, thus signals not handled in a
9999
timely manner will be dropped in favor of later arriving signals.
100100
101-
:mixed-exec/:io-exec/:compute-exec -> ExecutorService
102-
These can be used to specify the ExecutorService to use for the
101+
:mixed-exec/:io-exec/:compute-exec -> Executor
102+
These can be used to specify the Executor to use for the
103103
corresonding workload, in lieu of the lib defaults.
104104
105105
N.B. The flow is not started. See 'start'"
@@ -334,7 +334,7 @@
334334
335335
futurize accepts kwarg options:
336336
:exec - one of the workloads :mixed, :io, :compute
337-
or a j.u.c.ExecutorService object,
337+
or a j.u.c.Executor object,
338338
default :mixed"
339339
[f & {:keys [exec]
340340
:or {exec :mixed} :as opts}]

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@
1414
[clojure.core.async.impl.dispatch :as disp]
1515
[clojure.walk :as walk]
1616
[clojure.datafy :as datafy])
17-
(:import [java.util.concurrent Future Executors ExecutorService TimeUnit]
17+
(:import [java.util.concurrent Future Executors Executor TimeUnit]
1818
[java.util.concurrent.locks ReentrantLock]))
1919

2020
(set! *warn-on-reflection* true)
2121

2222
(defn datafy [x]
2323
(condp instance? x
2424
clojure.lang.Fn (-> x str symbol)
25-
ExecutorService (str x)
25+
Executor (str x)
2626
clojure.lang.Var (symbol x)
2727
(datafy/datafy x)))
2828

2929
(defn futurize [f {:keys [exec]}]
3030
(fn [& args]
31-
(let [^ExecutorService e (if (instance? ExecutorService exec)
32-
exec
33-
(disp/executor-for exec))]
34-
(.submit e ^Callable #(apply f args)))))
31+
(let [^Executor e (if (instance? Executor exec)
32+
exec
33+
(disp/executor-for exec))]
34+
(.execute e ^Runnable #(apply f args)))))
3535

3636
(defn prep-proc [ret pid {:keys [proc, args, chan-opts] :or {chan-opts {}}}]
3737
(let [{:keys [ins outs signal-select]} (spi/describe proc)
@@ -51,8 +51,8 @@
5151
(let [lock (ReentrantLock.)
5252
chans (atom nil)
5353
execs {:mixed mixed-exec :io io-exec :compute compute-exec}
54-
_ (assert (every? #(or (nil? %) (instance? ExecutorService %)) (vals execs))
55-
"mixed-exe, io-exec and compute-exec must be ExecutorServices")
54+
_ (assert (every? #(or (nil? %) (instance? Executor %)) (vals execs))
55+
"mixed-exe, io-exec and compute-exec must be Executors")
5656
pdescs (reduce-kv prep-proc {} procs)
5757
allopts (fn [iok] (into {} (mapcat #(map (fn [[k opts]] [[(:pid %) k] opts]) (iok %)) (vals pdescs))))
5858
inopts (allopts :ins)

0 commit comments

Comments
 (0)