lockfile

package
v0.0.0-...-921daf7 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2016 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyLocked = errors.New("another snappy is running, try again later")

ErrAlreadyLocked is returned when an attempts is made to lock an already-locked FileLock.

Functions

func WithLock

func WithLock(path string, f func() error) error

WithLock runs the function f while holding a Lock on the given file.

Types

type LockedFile

type LockedFile int

LockedFile is a handle you can use to Unlock a file lock.

func Lock

func Lock(path string, wait bool) (LockedFile, error)

Lock opens (and possibly creates) a new file at the given path and applies an exclusive advisory lock on it.

If the file already has an advisory lock, the `wait` flag determins whether to wait until it is removed or return ErrAlreadyLocked.

func (*LockedFile) Unlock

func (fd *LockedFile) Unlock() error

Unlock closes the file, thus also removing the advisary lock on it.

Jump to

Keyboard shortcuts

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