keymutex

package
v0.0.2 Latest Latest
Warning

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

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

README

keymutex-go

keymutex-go is a thread-safe mutex for acquiring locks on arbitrary strings which is from k8s/utils but zero allocate.

go test -v -benchmem -run="^$" github.com/detailyang/keymutex-go -bench Benchmark
goos: darwin
goarch: amd64
pkg: github.com/detailyang/keymutex-go
BenchmarkKeyMutex
BenchmarkKeyMutex-8   	31639718	        37.5 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/detailyang/keymutex-go	1.235s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyMutex

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

KeyMutex represents a mutex.

func New

func New(size int) *KeyMutex

New returns a new KeyMutex.

func (*KeyMutex) LockKey

func (km *KeyMutex) LockKey(id string)

Acquires a lock associated with the specified ID.

func (*KeyMutex) UnlockKey

func (km *KeyMutex) UnlockKey(id string)

Releases the lock associated with the specified ID.

Jump to

Keyboard shortcuts

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