all: Use new Go 1.19 atomic types (#8772)

This commit is contained in:
greatroar
2023-02-07 12:07:34 +01:00
committed by GitHub
parent 882b711958
commit 38f2b34d29
19 changed files with 94 additions and 121 deletions

View File

@@ -116,16 +116,16 @@ type loggedRWMutex struct {
readHolders map[int][]holder
readHoldersMut sync.Mutex
logUnlockers int32
logUnlockers atomic.Bool
unlockers chan holder
}
func (m *loggedRWMutex) Lock() {
start := timeNow()
atomic.StoreInt32(&m.logUnlockers, 1)
m.logUnlockers.Store(true)
m.RWMutex.Lock()
atomic.StoreInt32(&m.logUnlockers, 0)
m.logUnlockers.Store(false)
holder := getHolder()
m.holder.Store(holder)
@@ -173,7 +173,7 @@ func (m *loggedRWMutex) RUnlock() {
m.readHolders[id] = current[:len(current)-1]
}
m.readHoldersMut.Unlock()
if atomic.LoadInt32(&m.logUnlockers) == 1 {
if m.logUnlockers.Load() {
holder := getHolder()
select {
case m.unlockers <- holder: