syncutil

package
v2.11.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package syncutil provides mutex primitives with optional deadlock detection. Use build tag -tags=deadlock to enable deadlock detection during development.

Index

Constants

View Source
const DeadlockEnabled = false

DeadlockEnabled is true if the deadlock detector is enabled.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mutex

type Mutex struct {
	sync.Mutex //nolint:forbidigo // this package wraps sync.Mutex
}

A Mutex is a mutual exclusion lock.

type Pauser added in v2.11.0

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

Pauser is a thread-safe pause/resume primitive using the closed-channel pattern. When not paused, Wait returns immediately. When paused, Wait blocks until Resume is called or the context is cancelled.

A nil *Pauser is safe to use: Wait always returns nil.

func NewPauser added in v2.11.0

func NewPauser() *Pauser

NewPauser returns a Pauser in the unpaused state.

func (*Pauser) IsPaused added in v2.11.0

func (p *Pauser) IsPaused() bool

IsPaused reports whether the Pauser is currently in the paused state.

func (*Pauser) Pause added in v2.11.0

func (p *Pauser) Pause()

Pause requests a pause. Idempotent: calling Pause when already paused is a no-op.

func (*Pauser) Resume added in v2.11.0

func (p *Pauser) Resume()

Resume unblocks all goroutines waiting in Wait. Idempotent: calling Resume when not paused is a no-op.

func (*Pauser) Wait added in v2.11.0

func (p *Pauser) Wait(ctx context.Context) error

Wait blocks while the Pauser is paused. It returns nil immediately when not paused, blocks until Resume is called, or returns the context error if the context is cancelled while paused. A nil receiver returns nil.

type RWMutex

type RWMutex struct {
	sync.RWMutex //nolint:forbidigo // this package wraps sync.RWMutex
}

An RWMutex is a reader/writer mutual exclusion lock.

Jump to

Keyboard shortcuts

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