lock

package
v0.38.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLockAlreadyHeld     = errors.New("lock already held")
	ErrLockNotHeld         = errors.New("lock not held")
	ErrLockAlreadyAcquired = errors.New("lock already acquired by other")
)

Functions

This section is empty.

Types

type Locker added in v0.14.2

type Locker interface {
	/*
		Lock acquires a lock.

		The returned context will be cancelled when the lock is released.
			The following errors can occur:
			* ErrLockAlreadyHeld: it already had the lock
			* ErrLockAlreadyAcquired: the lock is already held by another lock
	*/
	Lock(context.Context) (context.Context, error)
	/*
		Unlock releases the lock, leading to the cancelling the context returned in Lock()

			The following errors can occur:
			* ErrLockNotHeld: releasing a lock that it was not previously acquired
	*/
	Unlock(context.Context) error

	// WaitForLock lock or wait until it locks or the context is cancelled.
	// The returned context will be cancelled when the lock is released.
	WaitForLock(context.Context) (context.Context, error)
}

type WaitForUnlocker added in v0.14.2

type WaitForUnlocker interface {
	// WaitForUnlock blocks until this lock is released
	WaitForUnlock(context.Context) error
}

type WaitLocker added in v0.25.0

type WaitLocker interface {
	Locker
	WaitForUnlocker
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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