This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-04
Channels
- # aleph (24)
- # beginners (60)
- # cider (20)
- # clara (4)
- # cljs-dev (13)
- # cljsrn (4)
- # clojure (66)
- # clojure-italy (32)
- # clojure-nl (4)
- # clojure-serbia (1)
- # clojure-uk (207)
- # clojurescript (115)
- # cursive (3)
- # datomic (36)
- # defnpodcast (1)
- # duct (15)
- # fulcro (14)
- # graphql (8)
- # lein-figwheel (1)
- # leiningen (4)
- # off-topic (140)
- # pedestal (40)
- # portkey (3)
- # reagent (40)
- # remote-jobs (1)
- # ring (11)
- # shadow-cljs (31)
- # spacemacs (6)
- # sql (65)
- # tools-deps (67)
- # yada (1)
@lxsameer stream/put!
doesn't block - it returns a Deferred
So let me rephrase my question, How can I put a value in an stream in a parallel fashion. Right now even if I consume from the stream and block in the consumer function it still runs my code in a thread
don't block in the consumer function - use deferred/zip
to collate responses once you have put all values on to the stream
oops, i think i may have misunderstood what you wrote
what's blocking ?
@mccraigmccraig let me show some code
@mccraigmccraig check this out http://dpaste.com/19CC303
the output of this code would be number 1-199 in order and all of them executed on the same thread.
In my understanding, the consume-async function should get a value from stream and apply the given fn to that value asynchronously
so if something is blocking the current thread (call to sleep) it should run fn in another thread in the threadpool
and if that's the case i should be able to see that some of those function runs in a different thread and the i should be able to see number printing on the out out of order ( with random sleep ofcourse )
hmm. i dunno - i would have expected that as well... things to look at - what happens if you use put-all!
with a range instead of put!
... what happens if you don't used a fixed-thread-executor
?
can you paste the output as well...
@mccraigmccraig result is the same with put-all!
as well
looking at the docs for consume-async
https://github.com/ztellman/manifold/blob/master/src/manifold/stream.clj#L483 this result seems in line with expectations... i don't think i've ever used consume-async