Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func (rw *RWMutex) Lock() {
- if race.Enabled {
- _ = rw.w.state
- race.Disable()
- }
- // First, resolve competition with other writers.
- rw.w.Lock()
- // Announce to readers there is a pending writer.
- r := atomic.AddInt32(&rw.readerCount, -rwmutexMaxReaders) + rwmutexMaxReaders
- // Wait for active readers.
- if r != 0 && atomic.AddInt32(&rw.readerWait, r) != 0 {
- runtime_Semacquire(&rw.writerSem)
- }
- if race.Enabled {
- race.Enable()
- race.Acquire(unsafe.Pointer(&rw.readerSem))
- race.Acquire(unsafe.Pointer(&rw.writerSem))
- }
Add Comment
Please, Sign In to add comment