locks

package
v0.147.2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const ErrNoLock consttypes.Error = "ErrNoLock"

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory added in v0.105.0

type Factory[Key comparable] interface {
	LockerFor(Key) Locker
}

type FactoryFunc added in v0.105.0

type FactoryFunc[Key comparable] func(Key) Locker

func (FactoryFunc[Key]) LockerFor added in v0.105.0

func (fn FactoryFunc[Key]) LockerFor(key Key) Locker

type Locker

type Locker interface {
	// Lock locks the Locker resource.
	// If the lock is already in use, the calling will be blocked until the locks is available.
	// It returns a context that represent a locked context, and an error that is nil if locking succeeded.
	// The returned context may hold locking related runtime states,
	// It might signal cancellation if the ownership of the lock is lost for some reason.
	Lock(ctx context.Context) (_lockCtx context.Context, _ error)
	// Unlock unlocks the Locker resource.
	// It is an error if Locker is not locked on entry to Unlock.
	//
	// It takes the context that Lock returned.
	Unlock(lockCtx context.Context) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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