flock

package
v0.3.14 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyLocked = errors.New("Double lock: already own the lock")
	ErrLockFailed    = errors.New("Could not acquire lock")
	ErrLockNotHeld   = errors.New("Could not unlock, lock is not held")

	ErrInodeChangedAtPath = errors.New("Inode changed at path")
)

Functions

This section is empty.

Types

type Flock

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

func New

func New(path string) *Flock

New returns a new instance of *Flock. The only parameter it takes is the path to the desired lockfile.

func (*Flock) Lock

func (f *Flock) Lock() error

Lock will acquire the lock. This function may block indefinitely if some other process holds the lock. For a non-blocking version, see Flock.TryLock().

func (*Flock) Path

func (f *Flock) Path() string

Path returns the file path linked to this lock.

func (*Flock) TryLock

func (f *Flock) TryLock() (bool, error)

TryLock will try to acquire the lock, and returns immediately if the lock is already owned by another process.

func (*Flock) Unlock

func (f *Flock) Unlock() error

Unlock removes the lock file from disk and releases the lock. Whatever the result of `.Unlock()`, the caller must assume that it does not hold the lock anymore.

Jump to

Keyboard shortcuts

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