lock

package
v0.0.0-...-3a545d7 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lock

type Lock struct {
	// contains filtered or unexported fields
}

Lock encapsulates the channel used to provide locking and unlocking capabilities. We don't want this channel exposed as someone may interact with it in malicious ways.

func New

func New() Lock

New creates a Lock and populates its channel. Once constructed, callers can use the Lock(ctx) method to lock a portion of code. Unlike the sync.Mutex implementation, this allows a Lock operation to be deadlined or cancelled using the provided context.

func (Lock) Lock

func (l Lock) Lock(ctx context.Context) (unlock func(), err error)

Lock attempts to obtain the lock given the provided context. This call can be time-bound using the context.WithDeadline method call to decorate the context with a halting point.

Jump to

Keyboard shortcuts

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