Hi all, please advice, does it make sense to use reduce with the pipeline-blocking?
(async/pipeline-blocking concurrent
output-chan
(reduce
(fn [acc hour]
(let [acc* (disj acc hour)]
(worker hour context)
(if (seq acc*)
acc*
(reduced :done))))
hours)
(async/to-chan hours))
What I want to achieve is to send :done
to output channel when all hours were processedwhy not use async/reduce
?
or something. You're not propagating the hours, you're working on them
So a way to use pipeline blocking would be
Create input channel with transducer cat
on it
Create output channel
Create pipeline blocking with transducer (map #(worker % context))
put hours
on the input channel
Then do some sort of take from the output channel <!!
/`<!`/`take!`.
That take will block until the work is finished
interesting... let me try. thanks!
works, thanks!
thanks
i haven't tried that before. async/pipeline-blocking
requires a transducer.
i've used pipeline-blocking
before, but with a transducer.
that is my concern, that reduce may not work 😞
thanks
I think pipeline-blocking returns channel which is close when processing is done.