Documentation ¶
Overview ¶
Package ctxlock provides a locking mechanism based on context cancellation.
Contexts derived from a Locker are canceled when the underlying connection to the lock provider is gone, or when a parent context is canceled.
This package makes use of "unsafe" to avoid some allocations, but the "safe" build tag can be provided to use allocating versions of the functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Locker ¶
type Locker struct {
// contains filtered or unexported fields
}
Locker provides context-scoped locks.
func New ¶
New creates a Locker that will pull connections from the provided pool.
The provided context is only used for logging and initial setup. Close must be called to release held resources.
func (*Locker) Lock ¶
Lock attempts to obtain the named lock until it succeeds or the passed Context is canceled.