kmutex

package
v0.0.0-...-bc5839e Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KMutex

type KMutex struct {
	sync.Mutex
	// contains filtered or unexported fields
}

KMutex is a lock implement. One key can acquire only one lock. There is no lock between different keys.

func New

func New() *KMutex

New creates a KMutex instance.

func (*KMutex) Lock

func (m *KMutex) Lock(k string) bool

Lock waits to acquire lock.

func (*KMutex) LockWithTimeout

func (m *KMutex) LockWithTimeout(k string, to time.Duration) bool

LockWithTimeout trys to lock, if can't acquire the lock, will block util timeout.

func (*KMutex) Trylock

func (m *KMutex) Trylock(k string) bool

Trylock trys to lock, will not block.

func (*KMutex) Unlock

func (m *KMutex) Unlock(k string)

Unlock release the lock.

Jump to

Keyboard shortcuts

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