locks

package
v0.0.0-...-d37b328 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LINUX_DIR_PATH = "/var/lock/mist-miner"

	OBJECTS_LOCKFILE         = "mm-objects.lock"
	HISTORY_LOCKFILE         = "mm-history-logger.lock"
	HISTORY_POINTER_LOCKFILE = "mm-history-pointer.lock"
	REF_MARK_LOCKFILE        = "mm-refmark.lock"
)

Variables

View Source
var ErrIsLocked = errors.New(
	"File is locked, another process is writing to it, wait and try again later.",
)

Functions

This section is empty.

Types

type Lock

type Lock struct {
	Flock *flock.Flock
	Path  string
}

func NewLock

func NewLock(group, filename string) (Lock, error)

NewLock creates a new Lock object with the given group and filename. the lock file will be created in the appropriate directory based on the OS. Example of lock file path will be like: OS_DIR_PATH/GROUP/FILENAME If group is empty, the lock file will be created in the root directory. Example of lock file path will be like: OS_DIR_PATH/FILENAME

func (*Lock) TryLock

func (l *Lock) TryLock() error

TryLock acquires an exclusive lock on the file. Is a wrapper for flock.Lock().

func (*Lock) TryRLock

func (l *Lock) TryRLock() error

TryRLock acquires a shared lock on the file. Is a wrapper for flock.RLock().

func (*Lock) Unlock

func (l *Lock) Unlock() error

Unlock releases the lock on the file. Is a wrapper for flock.Unlock().

Jump to

Keyboard shortcuts

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