Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SortableMutex ¶
type SortableMutex interface { sync.Locker Seq() uint64 AcquireDuration() time.Duration // The amount of time it took to acquire the lock }
SortableMutex provides a Mutex that can be globally sorted with other sortable mutexes. This allows deadlock-safe locking of a set of mutexes as it guarantees consistent lock ordering.
func NewSortableMutex ¶
func NewSortableMutex() SortableMutex
type SortableMutexes ¶
type SortableMutexes []SortableMutex
SortableMutexes is a set of mutexes that can be locked in a safe order. Once Lock() is called it must not be mutated!
func (SortableMutexes) Less ¶
func (s SortableMutexes) Less(i int, j int) bool
Less implements sort.Interface.
func (SortableMutexes) Lock ¶
func (s SortableMutexes) Lock()
Lock sorts the mutexes, and then locks them in order. If any lock cannot be acquired, this will block while holding the locks with a lower sequence number.
func (SortableMutexes) Swap ¶
func (s SortableMutexes) Swap(i int, j int)
Swap implements sort.Interface.
func (SortableMutexes) Unlock ¶
func (s SortableMutexes) Unlock()
Unlock locks the sorted set of mutexes locked by prior call to Lock().
Click to show internal directories.
Click to hide internal directories.