Documentation ¶
Index ¶
- type LockToken
- type Locker
- func (r *Locker) AsyncLockWithCtx(ctx context.Context) (LockToken, chan<- LockToken, error)
- func (r *Locker) RLock()
- func (r *Locker) RTryLockWithCtx(ctx context.Context) bool
- func (r *Locker) RUnlock()
- func (r *Locker) TryLockWithCtx(ctx context.Context) bool
- func (r *Locker) Unlock()
- func (r *Locker) WithLock(f func(l LockToken))
- func (r *Locker) WithLockInCtx(ctx context.Context, f func(l LockToken) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LockToken ¶ added in v1.2.0
type LockToken interface {
// contains filtered or unexported methods
}
LockToken represents proof that a list lock has been acquired
type Locker ¶ added in v1.2.0
type Locker struct {
// contains filtered or unexported fields
}
Locker
func (*Locker) AsyncLockWithCtx ¶ added in v1.2.0
AsyncLock acquires a lock until the token is returned to the receiving channel
func (*Locker) RTryLockWithCtx ¶ added in v1.2.0
RTryLockWithCtx tries to acquires a read lock with context and returns false if context is done, otherwise returns true.
func (*Locker) TryLockWithCtx ¶ added in v1.2.0
TryLockWithCtx tries to acquires a lock with context and returns false if context is done, otherwise returns true.
func (*Locker) WithLock ¶ added in v1.2.0
WithLock acquires a lock for the duration that the provided function is being executed. A token as proof of the lock is passed to the function.
func (*Locker) WithLockInCtx ¶ added in v1.2.0
WithLockInCtx tries to acquires a lock until it succeeds or context times out. If it fails, return value is false otherwise true. And, executes the function `f`, if lock is acquired. A token as proof of the lock is passed to the function.