Core async pipeline should return "to" channel.

104 views
Skip to first unread message

Claudius Nicolae

unread,
Apr 17, 2015, 3:33:58 PM4/17/15
to clo...@googlegroups.com
Since issue tracker for core.async is disabled on github, I'll spill this here.
I think "pipeline" should return the "to" channel, to make it threading-friendly:

(->> (range 100)
       (a/to-chan)
       (a/pipeline 10 (a/chan) (map inc))
       (a/pipeline 2 (a/chan) (filter odd?)))

Currently return value is incidental.

Francis Avila

unread,
Apr 17, 2015, 4:41:56 PM4/17/15
to clo...@googlegroups.com
Core.async issues are reported on Clojure's JIRA: http://dev.clojure.org/jira/browse/ASYNC

pipeline does not have an incidental return value: it returns a channel which closes when there are no more transformation results, i.e. when the pipelining "process" is finished. There is no other way to get this information, especially when close? is false.

You're right this hurts threading, but sometimes you do need to monitor when pipelining is done. In fact, the pipe function does return the to channel like you suggest, and I had to write my own version that returned its inner go-loop because I needed to monitor the piping process. https://gist.github.com/favila/8e7ad6ea5b01bd7466ff#file-async-util-clj-L27
Reply all
Reply to author
Forward
0 new messages