Unlock unlocks rw for writing. It is a run-time error if rw is not locked for writing on entry to Unlock.
As with Mutexes, a locked [RWMutex] is not associated with a particular goroutine. One goroutine may [RWMutex.RLock] ([RWMutex.Lock]) a RWMutex and then arrange for another goroutine to [RWMutex.RUnlock] ([RWMutex.Unlock]) it.
Generated using TypeDoc
A RWMutex is a reader/writer mutual exclusion lock. The lock can be held by an arbitrary number of readers or a single writer. The zero value for a RWMutex is an unlocked mutex.
A RWMutex must not be copied after first use.
If any goroutine calls [RWMutex.Lock] while the lock is already held by one or more readers, concurrent calls to [RWMutex.RLock] will block until the writer has acquired (and released) the lock, to ensure that the lock eventually becomes available to the writer. Note that this prohibits recursive read-locking.
In the terminology of the Go memory model, the n'th call to [RWMutex.Unlock] “synchronizes before” the m'th call to Lock for any n < m, just as for [Mutex]. For any call to RLock, there exists an n such that the n'th call to Unlock “synchronizes before” that call to RLock, and the corresponding call to [RWMutex.RUnlock] “synchronizes before” the n+1'th call to Lock.