Documentation ¶
Overview ¶
Package locking implements lock primitives with the correctness validator.
All mutexes are divided on classes and the validator check following conditions:
- Mutexes of the same class are not taken more than once except cases when that is expected.
- Mutexes are never locked in a reverse order. Lock dependencies are tracked on the class level.
The validator is implemented in a very straightforward way. For each mutex class, we maintain the ancestors list of all classes that have ever been taken before the target one. For each goroutine, we have the list of currently locked mutexes. And finally, all lock methods check that ancestors of currently locked mutexes don't contain the target one.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Mutex ¶
type Mutex struct {
// contains filtered or unexported fields
}
Mutex is sync.Mutex with the correctness validator.
func (*Mutex) NestedLock ¶
func (m *Mutex) NestedLock(i lockNameIndex)
NestedLock locks m knowing that another lock of the same type is held. +checklocksignore
func (*Mutex) NestedUnlock ¶
func (m *Mutex) NestedUnlock(i lockNameIndex)
NestedUnlock unlocks m knowing that another lock of the same type is held. +checklocksignore
type MutexClass ¶
type MutexClass struct{}
MutexClass is a stub class without the lockdep tag.
func NewMutexClass ¶
func NewMutexClass(reflect.Type, []string) *MutexClass
NewMutexClass is no-op without the lockdep tag.
type RWMutex ¶
type RWMutex struct {
// contains filtered or unexported fields
}
RWMutex is sync.RWMutex with the correctness validator.
func (*RWMutex) DowngradeLock ¶
func (m *RWMutex) DowngradeLock()
DowngradeLock atomically unlocks rw for writing and locks it for reading. +checklocksignore
func (*RWMutex) NestedLock ¶
func (m *RWMutex) NestedLock(i lockNameIndex)
NestedLock locks m knowing that another lock of the same type is held. +checklocksignore
func (*RWMutex) NestedUnlock ¶
func (m *RWMutex) NestedUnlock(i lockNameIndex)
NestedUnlock unlocks m knowing that another lock of the same type is held. +checklocksignore
func (*RWMutex) RLockBypass ¶
func (m *RWMutex) RLockBypass()
RLockBypass locks m for reading without executing the validator. +checklocksignore
func (*RWMutex) RUnlock ¶
func (m *RWMutex) RUnlock()
RUnlock undoes a single RLock call. +checklocksignore
func (*RWMutex) RUnlockBypass ¶
func (m *RWMutex) RUnlockBypass()
RUnlockBypass undoes a single RLockBypass call. +checklocksignore