keylock

package
v9.4.20+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrInvalidHandle

type ErrInvalidHandle struct {
	// ID unique object identifier.
	ID string
}

ErrInvalidHandle error type for invalid lock handle.

func (*ErrInvalidHandle) Error

func (e *ErrInvalidHandle) Error() string

type ErrKeyLockNotFound

type ErrKeyLockNotFound struct {
	// ID unique object identifier.
	ID string
}

ErrKeyLockNotFound error type for lock object not found

func (*ErrKeyLockNotFound) Error

func (e *ErrKeyLockNotFound) Error() string

type KeyLock

type KeyLock interface {
	// Acquire a lock associated with the specified ID.
	// Creates the lock if one doesn't already exist.
	Acquire(id string) LockHandle

	// Release the lock associated with the specified LockHandle
	// Returns an error if it is an invalid LockHandle.
	Release(h *LockHandle) error

	// Dump all locks.
	Dump() []string
}

KeyLock is a thread-safe interface for acquiring locks on arbitrary strings.

func ByName

func ByName(klName string) KeyLock

ByName creates a new instance or returns an existing instance if found in the map.

func New

func New() KeyLock

New returns a new instance of a KeyLock.

type LockHandle

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

LockHandle is an opaque handle to an aquired lock.

Jump to

Keyboard shortcuts

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