Question about golang source code in sync/mutex.go

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)?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.