locking

package
v0.0.0-...-c27c9a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2024 License: Apache-2.0, MIT, BSD-3-Clause Imports: 3 Imported by: 2

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

func AddGLock

func AddGLock(*MutexClass, int)

AddGLock is no-op without the lockdep tag.

func DelGLock

func DelGLock(*MutexClass, int)

DelGLock is no-op without the lockdep tag.

Types

type Mutex

type Mutex struct {
	// contains filtered or unexported fields
}

Mutex is sync.Mutex with the correctness validator.

func (*Mutex) Lock

func (m *Mutex) Lock()

Lock locks m. +checklocksignore

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

func (*Mutex) Unlock

func (m *Mutex) Unlock()

Unlock unlocks m. +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) Lock

func (m *RWMutex) Lock()

Lock locks m. +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) RLock

func (m *RWMutex) RLock()

RLock locks m for reading. +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

func (*RWMutex) Unlock

func (m *RWMutex) Unlock()

Unlock unlocks m. +checklocksignore

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL