safe

package
v3.8.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: GPL-3.0 Imports: 3 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

func Lock

func Lock(fn func(), m ...Mutex)

Lock locks one or more mutexes for writing and calls the given function. The mutexes are locked in a deterministic order to avoid deadlocks.

func LockRet

func LockRet[T any](fn func() T, m ...Mutex) T

LockRet locks one or more mutexes for writing and calls the given function, returning a value.

func LockRetErr

func LockRetErr[T any](fn func() (T, error), m ...Mutex) (T, error)

LockRetErr locks one or more mutexes for writing and calls the given function, returning a value and an error.

func RLock

func RLock(fn func(), m ...RWMutex)

RLock locks one or more mutexes for reading and calls the given function. The mutexes are locked in a deterministic order to avoid deadlocks.

func RLockRet

func RLockRet[T any](fn func() T, m ...RWMutex) T

RLockRet locks one or more mutexes for reading and calls the given function, returning a value.

func RLockRetErr

func RLockRetErr[T any](fn func() (T, error), m ...RWMutex) (T, error)

RLockRetErr locks one or more mutexes for reading and calls the given function, returning a value and an error.

Types

type Mutex

type Mutex interface {
	Lock()
	Unlock()
	// contains filtered or unexported methods
}

Mutex is a mutex that can be locked and unlocked.

func NewMutex

func NewMutex() Mutex

NewMutex returns a new mutex.

type RWMutex

type RWMutex interface {
	Mutex

	RLock()
	RUnlock()
}

RWMutex is a mutex that can be locked and unlocked for reading and writing.

func NewRWMutex

func NewRWMutex() RWMutex

NewRWMutex returns a new read-write mutex.

Jump to

Keyboard shortcuts

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