Documentation ¶
Overview ¶
Package syncutil provides various concurrency mechanisms.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GoroutineID ¶
func GoroutineID() int64
Types ¶
type Gate ¶
type Gate struct {
// contains filtered or unexported fields
}
A Gate limits concurrency.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
A Group is like a sync.WaitGroup and coordinates doing multiple things at once. Its zero value is ready to use.
func (*Group) Err ¶
Err waits for all previous calls to Go to complete and returns the first non-nil error, or nil.
func (*Group) Errs ¶
Errs waits for all previous calls to Go to complete and returns all non-nil errors.
type Once ¶
type Once struct {
// contains filtered or unexported fields
}
A Once will perform a successful action exactly once.
Unlike a sync.Once, this Once's func returns an error and is re-armed on failure.
func (*Once) Do ¶
Do calls the function f if and only if Do has not been invoked without error for this instance of Once. In other words, given
var once Once
if once.Do(f) is called multiple times, only the first call will invoke f, even if f has a different value in each invocation unless f returns an error. A new instance of Once is required for each function to execute.
Do is intended for initialization that must be run exactly once. Since f is niladic, it may be necessary to use a function literal to capture the arguments to a function to be invoked by Do:
err := config.once.Do(func() error { return config.init(filename) })
type RWMutexTracker ¶
type RWMutexTracker struct {
// contains filtered or unexported fields
}
RWMutexTracker is a sync.RWMutex that tracks who owns the current exclusive lock. It's used for debugging deadlocks.
func (*RWMutexTracker) Holder ¶
func (m *RWMutexTracker) Holder() string
Holder returns the stack trace of the current exclusive lock holder's stack when it acquired the lock (with Lock). It returns the empty string if the lock is not currently held.
func (*RWMutexTracker) Lock ¶
func (m *RWMutexTracker) Lock()
func (*RWMutexTracker) RLock ¶
func (m *RWMutexTracker) RLock()
func (*RWMutexTracker) RUnlock ¶
func (m *RWMutexTracker) RUnlock()
func (*RWMutexTracker) Unlock ¶
func (m *RWMutexTracker) Unlock()
type Sem ¶
type Sem struct {
// contains filtered or unexported fields
}
Sem implements a semaphore that can have multiple units acquired/released at a time.
func (*Sem) Acquire ¶
Acquire will deduct n units from the semaphore. If the deduction would result in the available units falling below zero, the call will block until another go routine returns units via a call to Release. If more units are requested than the semaphore is configured to hold, error will be non-nil.