keymutex

package
v1.13.5 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyMutex

type KeyMutex interface {
	// Acquires a lock associated with the specified ID, creates the lock if one doesn't already exist.
	LockKey(id string)

	// Releases the lock associated with the specified ID.
	// Returns an error if the specified ID doesn't exist.
	UnlockKey(id string) error
}

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

func NewHashed added in v1.12.0

func NewHashed(n int) KeyMutex

NewHashed returns a new instance of KeyMutex which hashes arbitrary keys to a fixed set of locks. `n` specifies number of locks, if n <= 0, we use number of cpus. Note that because it uses fixed set of locks, different keys may share same lock, so it's possible to wait on same lock.

Jump to

Keyboard shortcuts

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