Can you confirm:

* Today, calling put! on a closed channel throws an exception (according to its 
docstring).
* After this change, calling put! on a closed channel will return nil instead.

The current docstring says that the function will be called "when complete" 
which I took to mean when the value is actually placed in the channel (i.e., no 
longer pending) so I'm confused by your comment about pending puts... What 
happens if a put is enqueued on an open channel and then it is closed before 
the put is "complete"? It seems like put! would return true and the function 
would simply not be called?

Just trying to make sure I understand this properly.

I think it's a good change (even tho' it breaks any code that uses put! and 
expects it to throw an exception).

Sean

On Jan 23, 2014, at 6:05 AM, Timothy Baldridge <tbaldri...@gmail.com> wrote:
> I'm looking for some feedback on recent changes Rich and I have made to 
> core.async: 
> 
> I merged the "put ret" branch into master of core.async. This commit 
> introduces some changes to the core.async API that provides feedback during a 
> put! operation. 
> 
> The changes to the public api are fairly simple:
> 
> (let [result (put! c 42 (fn [result] nil))]
>   nil)
> 
> In this snippet, both result variables (in the callback and in the return 
> value) will return true, unless the channel is already closed. Since this 
> value is propagated to >! as well, termination of writers is now fairly easy:
> 
> (loop [x 0]
>   (when (>! c x)
>     (recur (inc x))))
> 
> Note: these new semantics don't change how pending puts are handled when a 
> channel closes. So if a put! returns true, the callback will not later be 
> called with false if the channel is closed. Once a put operation is enqueued 
> it will stay enqueued until a taker removes the operation. Close! will still 
> not remove pending puts. 
> 
> WARNING!!! The inclusion of these changes means we have to break the public 
> API. The function handed to put! now takes one argument instead of zero 
> arguments. This will instantly break any code that uses put!. Therefore when 
> upgrading to 0.1.0-SNAPSHOT you will need to update all calls to put!. I'm 
> sorry about this, but there's really no other way to get these changes into 
> the api. 
> 
> Please let me know about any bugs you find in the current 0.1.0-SNAPSHOT.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to