|
14 | 14 | [clojure.core.async.impl.dispatch :as disp] |
15 | 15 | [clojure.walk :as walk] |
16 | 16 | [clojure.datafy :as datafy]) |
17 | | - (:import [java.util.concurrent Future Executors ExecutorService TimeUnit] |
| 17 | + (:import [java.util.concurrent Future Executors Executor TimeUnit] |
18 | 18 | [java.util.concurrent.locks ReentrantLock])) |
19 | 19 |
|
20 | 20 | (set! *warn-on-reflection* true) |
21 | 21 |
|
22 | 22 | (defn datafy [x] |
23 | 23 | (condp instance? x |
24 | 24 | clojure.lang.Fn (-> x str symbol) |
25 | | - ExecutorService (str x) |
| 25 | + Executor (str x) |
26 | 26 | clojure.lang.Var (symbol x) |
27 | 27 | (datafy/datafy x))) |
28 | 28 |
|
29 | 29 | (defn futurize [f {:keys [exec]}] |
30 | 30 | (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))))) |
35 | 35 |
|
36 | 36 | (defn prep-proc [ret pid {:keys [proc, args, chan-opts] :or {chan-opts {}}}] |
37 | 37 | (let [{:keys [ins outs signal-select]} (spi/describe proc) |
|
51 | 51 | (let [lock (ReentrantLock.) |
52 | 52 | chans (atom nil) |
53 | 53 | 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") |
56 | 56 | pdescs (reduce-kv prep-proc {} procs) |
57 | 57 | allopts (fn [iok] (into {} (mapcat #(map (fn [[k opts]] [[(:pid %) k] opts]) (iok %)) (vals pdescs)))) |
58 | 58 | inopts (allopts :ins) |
|
0 commit comments