locksutil

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MPL-2.0 Imports: 3 Imported by: 37

Documentation

Index

Constants

View Source
const (
	LockCount = 256
)

Variables

This section is empty.

Functions

func LockIndexForKey

func LockIndexForKey(key string) uint8

Types

type DeadlockRWMutex added in v0.12.0

type DeadlockRWMutex struct {
	deadlock.RWMutex
}

DeadlockRWMutex is the RW version of DeadlockMutex.

func CreateLocksWithDeadlockDetection added in v0.12.0

func CreateLocksWithDeadlockDetection() []*DeadlockRWMutex

func LockForKeyWithDeadLockDetection added in v0.12.0

func LockForKeyWithDeadLockDetection(locks []*DeadlockRWMutex, key string) *DeadlockRWMutex

func LocksForKeysWithDeadLockDetection added in v0.12.0

func LocksForKeysWithDeadLockDetection(locks []*DeadlockRWMutex, keys []string) []*DeadlockRWMutex

type LockEntry

type LockEntry struct {
	sync.RWMutex
}

func CreateLocks

func CreateLocks() []*LockEntry

CreateLocks returns an array so that the locks can be iterated over in order.

This is only threadsafe if a process is using a single lock, or iterating over the entire lock slice in order. Using a consistent order avoids deadlocks because you can never have the following:

Lock A, Lock B Lock B, Lock A

Where process 1 is now deadlocked trying to lock B, and process 2 deadlocked trying to lock A

func LockForKey

func LockForKey(locks []*LockEntry, key string) *LockEntry

func LocksForKeys

func LocksForKeys(locks []*LockEntry, keys []string) []*LockEntry

Jump to

Keyboard shortcuts

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