aleph

lxsameer 2018-06-04T12:48:45.000096Z

How should I suppose to put a value on a manifold stream without blocking ?

mccraigmccraig 2018-06-04T13:14:14.000201Z

@lxsameer stream/put! doesn't block - it returns a Deferred

lxsameer 2018-06-04T13:16:48.000584Z

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

lxsameer 2018-06-04T13:17:01.000316Z

so it blocks

lxsameer 2018-06-04T13:17:11.000169Z

that thread

mccraigmccraig 2018-06-04T13:18:49.000269Z

don't block in the consumer function - use deferred/zip to collate responses once you have put all values on to the stream

mccraigmccraig 2018-06-04T13:19:17.000342Z

oops, i think i may have misunderstood what you wrote

mccraigmccraig 2018-06-04T13:19:37.000170Z

what's blocking ?

lxsameer 2018-06-04T14:06:47.000430Z

@mccraigmccraig let me show some code

lxsameer 2018-06-04T14:08:59.000660Z

@mccraigmccraig check this out http://dpaste.com/19CC303

lxsameer 2018-06-04T14:09:34.000306Z

the output of this code would be number 1-199 in order and all of them executed on the same thread.

lxsameer 2018-06-04T14:09:54.000081Z

In my understanding, the consume-async function should get a value from stream and apply the given fn to that value asynchronously

lxsameer 2018-06-04T14:11:28.000779Z

so if something is blocking the current thread (call to sleep) it should run fn in another thread in the threadpool

lxsameer 2018-06-04T14:12:32.000284Z

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 )

lxsameer 2018-06-04T14:12:42.000791Z

but it's not happening

lxsameer 2018-06-04T14:12:59.000819Z

if you want I can provide the output as well

mccraigmccraig 2018-06-04T14:16:38.000480Z

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 ?

lxsameer 2018-06-04T14:17:32.000335Z

I have to test the put-all! but without the executor the result would be the same

mccraigmccraig 2018-06-04T14:19:58.000221Z

can you paste the output as well...

lxsameer 2018-06-04T14:19:59.000307Z

@mccraigmccraig result is the same with put-all! as well

lxsameer 2018-06-04T14:20:36.000081Z

http://dpaste.com/0A3NC0X

lxsameer 2018-06-04T14:20:42.000344Z

reduced the number to 100

mccraigmccraig 2018-06-04T14:40:33.000455Z

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

lxsameer 2018-06-04T14:43:19.000329Z

hmmmm , very weird. It would be a good candidate for zack to include it in the naming chapter of elements of clojure