This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-22
Channels
- # beginners (104)
- # bitcoin (1)
- # boot (5)
- # clara (3)
- # cljs-dev (14)
- # cljsjs (5)
- # cljsrn (1)
- # clojure (242)
- # clojure-italy (17)
- # clojure-news (13)
- # clojure-norway (3)
- # clojure-russia (101)
- # clojure-spec (41)
- # clojure-uk (87)
- # clojurescript (38)
- # core-async (38)
- # cursive (6)
- # datomic (11)
- # defnpodcast (3)
- # docs (14)
- # editors (8)
- # events (1)
- # fulcro (7)
- # hoplon (25)
- # leiningen (4)
- # luminus (7)
- # off-topic (25)
- # onyx (1)
- # portkey (14)
- # random (1)
- # re-frame (7)
- # reagent (4)
- # rum (4)
- # schema (8)
- # shadow-cljs (257)
- # spacemacs (10)
- # specter (4)
- # unrepl (3)
- # yada (1)
anyone think the docstring for https://clojure.github.io/core.async/#clojure.core.async/pipeline-async is inconsistent with the behaviour of:
(async/pipeline-async
10
(async/chan 100)
#(async/thread (async/>!! %2 %1) (println "put " %1 " once") (async/>!! %2 %1) (println "put " %1 " twice"))
(async/to-chan (range 10)))
docstring specifically says "result(s)" but my reading of the code (and those results) is that af can only reliably place 1 result
“af must close! the channel before returning”
there is at least one pending ticket related to the docs for this
https://github.com/clojure/core.async/blob/master/src/test/clojure/clojure/core/pipeline_test.clj might be helpful for patterns too
so it works, but it's not asynchronous anymore after the first value is put on the channel
(async/pipeline-async
10
(async/chan 100)
#(async/thread
(async/>!! %2 %1)
(println "put " %1 " once")
(Thread/sleep 1000)
(async/>!! %2 %1)
(println "put " %1 " twice")
(Thread/sleep 1000)
(async/>!! %2 %1)
(println "put " %1 " thrice")
(Thread/sleep 1000)
(async/close! %2))
(async/to-chan (range 10)))
=>
#object[clojure.core.async.impl.channels.ManyToManyChannel
0x1be4a99a
"clojure.core.async.impl.channels.ManyToManyChannel@1be4a99a"]
put put 0 once5
put 4 once
put 1 once
once
put 2 once
put put 6 9 once
once
put put put 8 3 once
once
7 once
put 0 twice
put 0 thrice
put 1 twice
put 1 thrice
put 2 twice
put 2 thrice
put 3 twice
put 3 thrice
put 4 twice
put 4 thrice
put 5 twice
put 5 thrice
put 6 twice
put 6 thrice
put 7 twice
put 7 thrice
put 8 twice
put 8 thrice
put 9 twice
put 9 thrice
or.. it's "asynchronous" but the channels and threads block each other in such a way that things can only happen in sequence
I suppose that's probably necessary for "Outputs will be returned in order relative to the inputs." it's surprising though
it’s necessary for ordering