Documentation
¶
Index ¶
- type GetLockErr
- type Instance
- func (ins *Instance) Lock(timeout time.Duration) error
- func (ins *Instance) LockFn(timeout time.Duration, fn func() error) error
- func (ins *Instance) RLock(timeout time.Duration) error
- func (ins *Instance) RLockFn(timeout time.Duration, fn func() error) error
- func (ins *Instance) RUnlock()
- func (ins *Instance) Unlock()
- type Map
- type RWLocker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GetLockErr ¶
type GetLockErr struct {
// contains filtered or unexported fields
}
GetLockErr implements error interface. And it appends the information of the get lock request.
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance is a lock instance which is able to lock/unlock multiple namespaces at once.
Note that you can only create a valid instance by invoking Map.New(ctx, keys...).
func (*Instance) LockFn ¶
LockFn locks all underlying namespaces with a write lock and automatically unlock this locker when LockFn returned. It will keep contesting for the successful lock until it succeed or being timeout.
func (*Instance) RLockFn ¶
RLockFn locks all underlying namespaces with a read lock and automatically unlock this locker when LockFn returned. It will keep contesting for the successful lock until it succeed or being timeout.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is a namespace locks manager.
type RWLocker ¶
type RWLocker interface { LockFn(timeout time.Duration, fn func() error) error RLockFn(timeout time.Duration, fn func() error) error Lock(timeout time.Duration) error Unlock() RLock(timeout time.Duration) error RUnlock() }
RWLocker is a locker interface that provides read-write lock capabilities.