Pausing in mix is not effective


The following happens when using mix:


org.clojure/clojure "1.8.0", org.clojure/core.async "0.3.443"


Kevin Downey
January 13, 2020, 11:26 PM

fiddling with using priority can help alleviate this, but to some degree you will always be able to get at least one value from the c1 channel in the example above in the first read from mch, because the copying loop (from the channels in the mix to the output of the mix) reads from the channels and then blocks on writing to the output (in the example) which means it may have already read from c1 by the time c1 is paused.

Kevin Downey
January 13, 2020, 10:47 PM

This is due to how the go loop driving the mix is alerted to changes. The change notification goes on a channel that is then thrown in a collection with all the channels in the mix, and the go-loop does an alt on all the channels in that collection. alt is non-deterministic choice, so this means in theory the change channel could never be read, and the go-loop just goes on its way never getting changes.

This problem is exacerbated when the input channels are ready with lots of inputs as in the example above.

Your pinned fields
Click on the next to a field label to start pinning.