Fork me on GitHub
#core-async
<
2018-05-02
>
tbaldridge01:05:11

@lxsameer or if you use put! make sure you also use a callback that limits how soon you call put! again. That's really the key here, put! requires manual implementation of backpressure

tbaldridge01:05:28

Sometimes that's easy (like when dealing with a async message queue), sometimes it's harder

tbaldridge01:05:50

A go-loop that pipes from in to out is really nothing more than this:

(defn pipe [in out]
  (take! in
            (fn [val]
              (when val
                (put! out 
                   (fn [put?}
                     (when put?
                       (pipe in out)))))))) 
That handles back pressure just fine, but as you can see it's a bit more ugly than:
(defn pipe [in out
  (go-loop []
    (when-some [val (<! in)]
      (when (>! out val)
        (recur)))))