lock

package
v1.5.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2023 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

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 NewLocker added in v1.2.0

func NewLocker() *Locker

func (*Locker) AsyncLockWithCtx added in v1.2.0

func (r *Locker) AsyncLockWithCtx(ctx context.Context) (LockToken, chan<- LockToken, error)

AsyncLock acquires a lock until the token is returned to the receiving channel

func (*Locker) RLock added in v1.2.0

func (r *Locker) RLock()

RLock acquires a read lock

func (*Locker) RTryLockWithCtx added in v1.2.0

func (r *Locker) RTryLockWithCtx(ctx context.Context) bool

RTryLockWithCtx tries to acquires a read lock with context and returns false if context is done, otherwise returns true.

func (*Locker) RUnlock added in v1.2.0

func (r *Locker) RUnlock()

RUnlock releases a read lock

func (*Locker) TryLockWithCtx added in v1.2.0

func (r *Locker) TryLockWithCtx(ctx context.Context) bool

TryLockWithCtx tries to acquires a lock with context and returns false if context is done, otherwise returns true.

func (*Locker) Unlock added in v1.2.0

func (r *Locker) Unlock()

Unlock releases a lock

func (*Locker) WithLock added in v1.2.0

func (r *Locker) WithLock(f func(l LockToken))

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

func (r *Locker) WithLockInCtx(ctx context.Context, f func(l LockToken) error) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL