Skip to content

Commit ceaa94b

Browse files
committed
don't direct connect 1:1 feedback conns
1 parent 2c7d7a5 commit ceaa94b

File tree

1 file changed

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

1 file changed

+6
-3
lines changed

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,21 @@
108108
nil))
109109
(async/chan (or buf-or-n 10))))
110110
in-chans (zipmap (keys inopts) (map make-chan inopts))
111+
needs-mult? (fn [out ins]
112+
(or (< 1 (count ins))
113+
(= (first out) (ffirst ins))))
111114
out-chans (zipmap (keys outopts)
112115
(map (fn [[coord opts :as co]]
113116
(let [conns (conn-map coord)]
114117
(cond
115118
(empty? conns) nil
119+
(needs-mult? coord conns) (make-chan co)
116120
;;direct connect 1:1
117-
(= 1 (count conns)) (in-chans (first conns))
118-
:else (make-chan co))))
121+
:else (in-chans (first conns)))))
119122
outopts))
120123
;;mults
121124
_ (doseq [[out ins] conn-map]
122-
(when (< 1 (count ins))
125+
(when (needs-mult? out ins)
123126
(let [m (async/mult (out-chans out))]
124127
(doseq [in ins]
125128
(async/tap m (in-chans in))))))

0 commit comments

Comments
 (0)