<< Back to previous view

[ASYNC-191] storage-buffer and storage-chan Created: 19/May/17  Updated: 19/May/17  Resolved: 19/May/17

Status: Closed
Project: core.async
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Vitalie Spinu Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: enhancement


 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.



 Comments   
Comment by Alex Miller [ 19/May/17 8:06 AM ]

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

Comment by Vitalie Spinu [ 19/May/17 9:18 AM ]

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?





[ASYNC-38] keep</> instead of map</> Created: 18/Nov/13  Updated: 02/Sep/14  Resolved: 02/Sep/14

Status: Closed
Project: core.async
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Leon Grapenthin Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: documentation, enhancement, errormsgs


 Description   

One problem with using map< is when the supplied function returns nil. In such case (using the latest implementation from core.async [org.clojure/core.async "0.1.256.0-1bf8cf-alpha"]) one can take nil from a channel created with map<. This is otherwise only possible with closed channels. Putting nil on a channel normally throws an IllegalArgumentException.

With the current implementation of map< it is not possible to determine whether the source-channel was closed or the supplied function returned nil.

Notice that putting onto a channel created with map> throws an IllegalArgumentException when the supplied function returns nil as if you would put nil onto a channel.

My proposal is to add keep</> (where nil values returned from the supplied function are ignored and nothing is put) to the core library or to implement map</> as keep</> since having a real map</> instead of keep</> hardly makes sense when nil is not permitted anyways.



 Comments   
Comment by Leon Grapenthin [ 24/Apr/14 3:44 AM ]

It is still an issue in "0.1.278.0-76b25b-alpha" that you can only use impl.protocols/closed? to consistently determine whether a channel created with map</> was closed - if nil is one of your predicates return values.

Of course, you could use a predicate that never returns nil. But what should be the benefit of map</> being able to magically pass nil while everything else isn't?

Comment by Alex Miller [ 02/Sep/14 9:43 AM ]

All of the transformation functions (like map<) are deprecated and will go away to be replaced with applying transducers to channels.





Generated at Mon Sep 25 08:29:17 CDT 2017 using JIRA 4.4#649-r158309.