multimutex

package
v0.18.4-beta.rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mutex

type Mutex[T comparable] struct {
	// contains filtered or unexported fields
}

Mutex is a struct that keeps track of a set of mutexes with a given ID. It can be used for making sure only one goroutine gets given the mutex per ID.

func NewMutex

func NewMutex[T comparable]() *Mutex[T]

NewMutex creates a new Mutex.

func (*Mutex[T]) Lock

func (c *Mutex[T]) Lock(id T)

Lock locks the mutex by the given ID. If the mutex is already locked by this ID, Lock blocks until the mutex is available.

func (*Mutex[T]) Unlock

func (c *Mutex[T]) Unlock(id T)

Unlock unlocks the mutex by the given ID. It is a run-time error if the mutex is not locked by the ID on entry to Unlock.

Jump to

Keyboard shortcuts

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