internal

package
v0.0.0-...-7cd6fd4 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

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) Len

func (s SortableMutexes) Len() int

Len implements sort.Interface.

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().

Jump to

Keyboard shortcuts

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