syncz

package
v15.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunWithMutex added in v15.7.0

func RunWithMutex[T any](mu *sync.Mutex, f func() T) T

Types

type Mutex

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

Mutex is a non-reentrant (like sync.Mutex) mutex that (unlike sync.Mutex) allows to acquire the mutex with a possibility to abort the attempt early if a context signals done.

A buffered channel of size 1 is used as the mutex. Think of it as of a box - the party that has put something into it has acquired the mutex. To unlock it, remove the contents from the box, so that someone else can use it. An empty box is created in the NewMutex() constructor.

TryLock, Lock, and Unlock provide memory access ordering guarantees by piggybacking on channel's "happens before" guarantees. See https://golang.org/ref/mem

func NewMutex

func NewMutex() Mutex

func (Mutex) Lock

func (m Mutex) Lock(ctx context.Context) bool

func (Mutex) RunLocked

func (m Mutex) RunLocked(ctx context.Context, f func()) bool

func (Mutex) TryLock

func (m Mutex) TryLock() bool

func (Mutex) Unlock

func (m Mutex) Unlock()

type RWMutex

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

func NewRWMutex

func NewRWMutex() RWMutex

func (RWMutex) Lock

func (m RWMutex) Lock(ctx context.Context) bool

func (RWMutex) RLock

func (m RWMutex) RLock(ctx context.Context) bool

func (RWMutex) RUnlock

func (m RWMutex) RUnlock()

func (RWMutex) Unlock

func (m RWMutex) Unlock()

Jump to

Keyboard shortcuts

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