storage-buffer and storage-chan

Description

Would it be possible to add a buffer that `constantly` emits the last placed value? It's effectively a storage cell which behaves like already implemented `promise-buffers`, but allows for new values to be put on the chan.

The motivation is as follows. If some sub-system computes statistics and places them on a chan, receivers could pick up the most recent value without bothering to store it themselves. In my application this would completely eliminate all needs for mutable storage.

Sorry if this feature already exists or is trivial to implement. I couldn't find anything relevant on this.

Environment

None

Activity

Show:
Alex Miller
May 19, 2017, 2:06 PM

I don't think we're going to add this but I suspect you could make a custom buffer pretty easily that did this.

Vitalie Spinu
May 19, 2017, 3:18 PM

I currently do it by relying on implementation details in clojure.core.async.impl which is not ideal. Or did you have something else in mind?
AFAICT promise-chan can be easily mimicked by constant go-loop, but mimicking storage buffer is a non-trivial business.

Any specific reason for the decline? Is it a bad idea to use channels in this way?

Declined

Assignee

Unassigned

Reporter

Vitalie Spinu

Labels

None

Approval

None

Patch

None

Priority

Minor