sync

package module
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MPL-2.0 Imports: 13 Imported by: 511

Documentation

Overview

Package sync is an extension of the stdlib "sync" package. It has extra functionality that helps debug the use of synchronization primitives. The package should be importable in place of "sync". The extra functionality can be enabled by calling Enable() or passing a non-empty PPROF_SYNC environment variable to the process.

Several profiles are exposed on the default HTTP muxer (and to "/debug/pprof" when "net/http/pprof" is imported by the process). "lockHolders" lists the stack traces of goroutines that called Mutex.Lock that haven't subsequently been Unlocked. "lockBlockers" contains goroutines that are waiting to obtain locks. "/debug/lockTimes" or PrintLockTimes() shows the longest time a lock is held for each stack trace.

Note that currently RWMutex is treated like a Mutex when the package is enabled.

Index

Constants

This section is empty.

Variables

View Source
var OnceFunc = sync.OnceFunc

Functions

func Enable

func Enable()

func EnableContention

func EnableContention()

func EnableLockTimes

func EnableLockTimes()

func PrintLockTimes

func PrintLockTimes(w io.Writer)

Writes out the longest time a Mutex remains locked for each stack trace that locks a Mutex.

Types

type Cond

type Cond = sync.Cond

type Locker

type Locker = sync.Locker

type Map

type Map = sync.Map

type Mutex

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

func (*Mutex) Lock

func (m *Mutex) Lock()

func (*Mutex) Unlock

func (m *Mutex) Unlock()

type Once

type Once = sync.Once

type Pool

type Pool = sync.Pool

type RWMutex

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

This RWMutex's RLock and RUnlock methods don't allow shared reading because there's no way to determine what goroutine has stopped holding the read lock when RUnlock is called. So for debugging purposes when the package is Enable()d, it's just like Mutex.

func (*RWMutex) Lock

func (me *RWMutex) Lock()

func (*RWMutex) RLock

func (me *RWMutex) RLock()

func (*RWMutex) RUnlock

func (me *RWMutex) RUnlock()

func (*RWMutex) Unlock

func (me *RWMutex) Unlock()

type WaitGroup

type WaitGroup = sync.WaitGroup

Jump to

Keyboard shortcuts

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