Documentation
¶
Index ¶
- Variables
- func NewLocker() lock.Locker
- func NewRWLocker() lock.RWLocker
- type Locker
- type RWLocker
- func (rw *RWLocker) Lock(ctx context.Context, key string, _ time.Duration) error
- func (rw *RWLocker) RLock(ctx context.Context, key string, _ time.Duration) error
- func (rw *RWLocker) RUnlock(_ context.Context, key string) error
- func (rw *RWLocker) TryLock(ctx context.Context, key string, _ time.Duration) (bool, error)
- func (rw *RWLocker) Unlock(ctx context.Context, key string) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUnlockUnknownKey is returned when attempting to unlock a key that is not locked. ErrUnlockUnknownKey = fmt.Errorf("local.Locker: unlock of unknown key") // ErrRUnlockUnknownKey is returned when attempting to runlock a key that is not locked. ErrRUnlockUnknownKey = fmt.Errorf("local.Locker: runlock of unknown key") )
Functions ¶
func NewRWLocker ¶
NewRWLocker creates a new local read-write locker.
Types ¶
type Locker ¶
type Locker struct {
// contains filtered or unexported fields
}
Locker implements lock.Locker using per-key mutexes. Uses a map of mutexes to provide true per-key locking semantics without the risk of shard collisions. Ref-counting is used to clean up mutexes when they are no longer in use.
type RWLocker ¶
type RWLocker struct {
// contains filtered or unexported fields
}
RWLocker implements lock.RWLocker using per-key RWMutexes.
Click to show internal directories.
Click to hide internal directories.