On Wed, Nov 30, 2016 at 2:01 PM, Daniel Fanjul <daniel.fanjul.alcu...@gmail.com> wrote: > I was going to answer no, but after a careful review of the go memory model > section regarding locks, I am replying: yes, I would. > > Because the memory model only specifies "happens before" restrictions > between calls to Lock() and Unlock() and that is not this case. > "For any sync.Mutex or sync.RWMutex variable l and n < m, call n of > l.Unlock() happens before call m of l.Lock() returns." > "For any call to l.RLock on a sync.RWMutex variable l, there is an n such > that the l.RLock happens (returns) after call n to l.Unlock and the matching > l.RUnlock happens before call n+1 to l.Lock." > > The inner most goroutine would run the assignment and a call to l.Lock() or > l.Unlock(). You can still swap the actions and "the [resulting] reordering > does not change the behavior within that goroutine as defined by the > language specification".
OK, I think this is https://golang.org/issue/7948. Ian -- 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.