Mutex.TryLock is implemented as the below. The second line is fetching value of the state but it does not use atomic. Is it is a race issue?
Should type of the state be changed to atomic.Int32 just like Waitgroup? func (m *Mutex) TryLock() bool { old := m.state if old&(mutexLocked|mutexStarving) != 0 { return false } if !atomic.CompareAndSwapInt32(&m.state, old, old|mutexLocked) { return false } if race.Enabled { race.Acquire(unsafe.Pointer(m)) } return true } -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/c076387c-aef7-4960-afc1-dbe67ed4fa48n%40googlegroups.com.