thanks for sharing your implementation. I have a few questions. 1. is NewCond needed? Is this sufficient?
var c Cond c.Notify() 2. In notify, is the two arg form of the .(*barr) conversion necessary? If the value is not initialised then the assertion to *barr will fail. If it is initiased then the assertion will pass and therefore b is not nil. 3. I wonder if channels can be lost on line 43-47. For example like 44 succceds and the first goroutine enters the block but has not yet reached line 45, meanwhile a second goroutine enters line 43, fails the condition at line 44 and then overwrites the value stored on line 47, then the first goroutine completes the block and itself reaches line 47 overwriting the value stored in the atomic value. At this point there may be two channels being waited on by callers to Block, but one has been lost permanently. On Thursday, 30 November 2017 22:51:08 UTC+11, Artyom Pervukhin wrote: > > Hi, > > Some time ago I had a similar use-case and came up with the following > pattern: https://play.golang.org/p/zQglq3ObvH — it's based on guarantee > that receive operation on a closed channel always proceeds immediately. > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.