sync

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MutexMap

type MutexMap[K comparable] struct {
	// contains filtered or unexported fields
}

MutexMap is a map of mutexes by a given key type [K].

The map keeps track of entities trying to lock a certain key. Upon releasing a key, if no entity wants to lock a key, the key is deleted from the map, keeping it as small as possible.

func NewMutexMap

func NewMutexMap[K comparable]() *MutexMap[K]

NewMutexMap creates a new MutexMap.

func (*MutexMap[K]) Count

func (m *MutexMap[K]) Count(key K) int

Count returns the number of locking entities for a given key. If a key is not present, 0 is returned.

func (*MutexMap[K]) Len

func (m *MutexMap[K]) Len() int

Len returns the number of entries in the MutexMap.

func (*MutexMap[K]) Lock

func (m *MutexMap[K]) Lock(key K)

Lock locks the given key.

func (*MutexMap[K]) Locker

func (m *MutexMap[K]) Locker(key K) sync.Locker

Locker returns a sync.Locker that locks / unlocks the given key in the MutexMap.

func (*MutexMap[K]) Unlock

func (m *MutexMap[K]) Unlock(key K)

Unlock unlocks the given key.

Jump to

Keyboard shortcuts

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