lockers

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileLock

type FileLock interface {
	// Lock try locking file, return err if fails.
	Lock() error
	// Unlock unlock file lock, if fail return err
	Unlock() error
}

FileLock represents file lock

func NewFileLock

func NewFileLock(fileName string) (FileLock, error)

NewFileLock create new file lock instance

type SpinLock

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

SpinLock implements sync/Locker, default 0 indicates an unlocked spinLock.

func (*SpinLock) Lock

func (sl *SpinLock) Lock()

Lock locks spinLock. If the lock is locked before, the caller will be blocked until unlocked.

func (*SpinLock) TryLock

func (sl *SpinLock) TryLock() bool

TryLock will try to lock spinLock and return whether it succeed or not without blocking.

func (*SpinLock) Unlock

func (sl *SpinLock) Unlock()

Unlock unlocks spinLock, this operation is reentrant。

Jump to

Keyboard shortcuts

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