草庐IT

rwmutexMaxReaders

全部标签

go - Golang 中 RWMutex.Lock() 的实现

在src/sync/rwmutex.go文件中,我们可以看到“Lock”的定义如下:func(rw*RWMutex)Lock(){ifrace.Enabled{_=rw.w.staterace.Disable()}//First,resolvecompetitionwithotherwriters.rw.w.Lock()//Announcetoreadersthereisapendingwriter.r:=atomic.AddInt32(&rw.readerCount,-rwmutexMaxReaders)+rwmutexMaxReaders//Waitforactivereaders

go - Golang 中 RWMutex.Lock() 的实现

在src/sync/rwmutex.go文件中,我们可以看到“Lock”的定义如下:func(rw*RWMutex)Lock(){ifrace.Enabled{_=rw.w.staterace.Disable()}//First,resolvecompetitionwithotherwriters.rw.w.Lock()//Announcetoreadersthereisapendingwriter.r:=atomic.AddInt32(&rw.readerCount,-rwmutexMaxReaders)+rwmutexMaxReaders//Waitforactivereaders