On Fri, Mar 9, 2018 at 8:19 AM Andrey Tcherepanov < xnow4fippy...@sneakemail.com> wrote:
> So if this is a "just" a mutex, this whole thing will not be atomic - it would introduce intermediate (albeit invisible) between "<-" parts. I was hoping for the "edge collapse" here. Not sure IIUC, but I should have probably emphasized that the "atomicity" can be seen over the single send or receive _operation_ only. Within a send or receive _statement_ the situation is more complex. For instance, in 'ch <- f()', the RHS is evaluated before the send operation is even attempted. The send operation may block giving another goroutine a chance, for example, to call f() again and send to 'ch' before the first caller of 'f()' gets unblocked. Considering r := make(chan int, 100) w := make(chan int, 100) go func() { i := 0 for { ch <- i i++ } } go func() { for { w <- <-r } } go func() { for { w <- <-r } } We cannot rely on values pulled later from 'w' will to be in order even though values put into 'r' are guaranteed to be such. -- -j -- 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.