sync: github.com/anacrolix/sync Index | Files

package sync

import "github.com/anacrolix/sync"

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

Package Files

aliases.go lockstats.go mutex.go rwmutex.go sync.go

func Enable Uses

func Enable()

func EnableContention Uses

func EnableContention()

func EnableLockTimes Uses

func EnableLockTimes()

func PrintLockTimes Uses

func PrintLockTimes(w io.Writer)

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

type Cond Uses

type Cond = sync.Cond

type Locker Uses

type Locker = sync.Locker

type Mutex Uses

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

func (*Mutex) Lock Uses

func (m *Mutex) Lock()

func (*Mutex) Unlock Uses

func (m *Mutex) Unlock()

type Pool Uses

type Pool = sync.Pool

type RWMutex Uses

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 Uses

func (me *RWMutex) Lock()

func (*RWMutex) RLock Uses

func (me *RWMutex) RLock()

func (*RWMutex) RUnlock Uses

func (me *RWMutex) RUnlock()

func (*RWMutex) Unlock Uses

func (me *RWMutex) Unlock()

type WaitGroup Uses

type WaitGroup = sync.WaitGroup

Package sync imports 13 packages (graph) and is imported by 36 packages. Updated 2018-09-01. Refresh now. Tools for package owners.