syncutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LockGroup

type LockGroup struct {
	// contains filtered or unexported fields
}

LockGroup is a map of mutex that locks entries with different id separately. It's used levitate lock contentions of using a global lock.

func NewLockGroup

func NewLockGroup(options ...LockGroupOption) *LockGroup

NewLockGroup create and return an empty lockGroup.

func (*LockGroup) Lock

func (g *LockGroup) Lock(id uint32)

Lock locks the target mutex base on the hash of id.

func (*LockGroup) Unlock

func (g *LockGroup) Unlock(id uint32)

Unlock unlocks the target mutex based on the hash of the id.

type LockGroupOption

type LockGroupOption func(lg *LockGroup)

LockGroupOption configures the lock group.

func WithHash

func WithHash(hashFn func(id uint32) uint32) LockGroupOption

WithHash sets the lockGroup's hash function to provided hashFn.

type Mutex

type Mutex struct {
	sync.Mutex
}

Mutex is a mutual exclusion lock. The zero value for a Mutex is an unlocked mutex.

Mutex must not be copied after first use.

type RWMutex

type RWMutex struct {
	sync.RWMutex
}

RWMutex is a reader/writer mutual exclusion lock. The lock can be held by an arbitrary number of readers or a single writer. The zero value for a RWMutex is an unlocked mutex.

RWMutex must not be copied after first use.

Jump to

Keyboard shortcuts

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