Skip to content

Commit 5d4b3bd

Browse files
committed
Merge branch 'master' into dev-io-thread
2 parents 66f985c + 8ed01ad commit 5d4b3bd

File tree

1 file changed

+3
-26
lines changed
  • src/main/clojure/clojure/core/async/flow

1 file changed

+3
-26
lines changed

Diff for: src/main/clojure/clojure/core/async/flow/impl.clj

+3-26
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,11 @@
2323
(defonce io-exec clojure.lang.Agent/soloExecutor)
2424
(defonce compute-exec clojure.lang.Agent/pooledExecutor)
2525

26-
(defn oid [x]
27-
(symbol (str (-> x class .getSimpleName) "@" (-> x System/identityHashCode Integer/toHexString))))
28-
29-
(defn chan->data
30-
[^clojure.core.async.impl.channels.ManyToManyChannel c]
31-
(let [b (.buf c)]
32-
{:buffer (if (some? b) (oid b) :none)
33-
:buffer-count (count b)
34-
:put-count (count (.puts c))
35-
:take-count (count (.takes c))
36-
:closed? (clojure.core.async.impl.protocols/closed? c)}))
37-
38-
(defn exec->data [exec]
39-
(let [ess (as-> (str exec) ^String es
40-
(.substring es (inc (.lastIndexOf es "[")) (.lastIndexOf es "]"))
41-
(.split es ","))]
42-
(merge {:id (oid exec)
43-
:status (first ess)} ;;TODO less fragile
44-
(zipmap [:pool-size :active-threads :queued-tasks :completed-tasks]
45-
(map #(-> ^String % (.substring (inc (.lastIndexOf ^String % " "))) Long.) (rest ess))))))
46-
4726
(defn datafy [x]
4827
(condp instance? x
4928
clojure.lang.Fn (-> x str symbol)
50-
ExecutorService (exec->data x)
29+
ExecutorService (str x)
5130
clojure.lang.Var (symbol x)
52-
clojure.core.async.impl.channels.ManyToManyChannel (chan->data x)
5331
(datafy/datafy x)))
5432

5533
(defn futurize ^Future [f {:keys [exec]}]
@@ -242,9 +220,8 @@
242220
(loop [nstatus nstatus, nstate nstate, msgs (seq msgs)]
243221
(if (or (nil? msgs) (= nstatus :exit))
244222
[nstatus nstate]
245-
(let [m (if-some [m (first msgs)] m (throw (Exception. "messages must be non-nil")))
246-
[v c] (async/alts!!
247-
[control [outc m]]
223+
(let [[v c] (async/alts!!
224+
[control [outc (first msgs)]]
248225
:priority true)]
249226
(if (= c control)
250227
(let [nnstatus (handle-command nstatus v)

0 commit comments

Comments
 (0)