lockfile

package
v0.0.0-...-5b4bc19 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2015 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package lockfile defines a flock(2)-based implementation of the file lock.

Index

Constants

View Source
const (
	FileOpenFlags   = os.O_RDONLY
	FileCreateFlags = os.O_CREATE | os.O_EXCL | FileOpenFlags
)

File* constants family defines flags which are used to open lock files.

View Source
const FileMode = os.FileMode(0666)

FileMode defines default permission for file lock open.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lock

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

Lock file is a thin wrapper around os.File to give user a possibility to use file as a lock (using flock(2))

func NewLock

func NewLock(filename string) *Lock

NewLock returns new lock instance. Argument is a path to the lock file. Please remember that file would be truncated so it should be file path for absent file or something which has insensitive content.

func (*Lock) Acquire

func (l *Lock) Acquire() (err error)

Acquire file lock. Returns error if acquiring failed, nil otherwise.

func (*Lock) Release

func (l *Lock) Release() error

Release file lock. Returns error if something went wrong, nil otherwise.

func (*Lock) String

func (l *Lock) String() string

Jump to

Keyboard shortcuts

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