First pending put into a channel always succeeds even if the buffer is full

Description

Say we have a channel with a fixed buffer and a generating transducer (e.g. cat), and a pending put is scheduled into that channel. Then, the take from the channel will invoke the first pending put, even if the buffer is still full after the take.

Example scenario:

Because of this, I cannot use backpressure with generative transducers, since the size of the fixed buffer, in this case, may grow infinitely.

I believe, the issue is here: https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/channels.clj#L182. If the buffer was checked for fullness before the first pending put is executed, the issue would be solved. If this is confirmed to be a bug (not the intended behavior) I will submit a patch.

Environment

[org.clojure/clojure "1.9.0-alpha10"]
[org.clojure/core.async "0.2.385"]

Activity

Show:

Alex Miller February 13, 2017 at 8:41 PM

This is the expected behavior. Expanding transducers must always be able to put and are allowed to do so even when the buffer is full. If this is an issue for back-pressure for you, you should pull the transducer out of the channel and do the expansion in a go process.

Declined

Details

Assignee

Reporter

Priority

Created September 16, 2016 at 1:54 PM
Updated February 13, 2017 at 8:41 PM
Resolved February 13, 2017 at 8:41 PM