mutex

package
v0.407.4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 1 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 any] struct {
	// contains filtered or unexported fields
}

Mutex is a simple mutex that can be used to protect a value.

The zero value is safe to use if the zero value of T is safe to use.

Example:

var m mutex.Mutex[*string]
s := m.Lock()
defer m.Unlock()
*s = "hello"

func New

func New[T any](v T) *Mutex[T]

func (*Mutex[T]) Lock

func (l *Mutex[T]) Lock() T

Lock the Mutex and return its protected value.

func (*Mutex[T]) Unlock

func (l *Mutex[T]) Unlock()

Unlock the Mutex. The value returned by Lock is no longer valid.

Jump to

Keyboard shortcuts

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