Original post

I’ve been learning golang source code. And I have a question about line 164 in sync/mutex.go:

Why not use atomic.LoadInt32, just like line 381 in sync/map.go:

func (e *entry) tryExpungeLocked() (isExpunged bool) {
        p := atomic.LoadPointer(&e.p)
        for p == nil {
                if atomic.CompareAndSwapPointer(&e.p, nil, expunged) {
                        return true
                }
                p = atomic.LoadPointer(&e.p) // line 381
        }
        return p == expunged
}


Is there no concurrency problem in this case(line 164 in sync/mutex.go)?