flock

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2015 License: MIT Imports: 3 Imported by: 0

README

flock

GoDoc

Package flock provides a simple file locking mechanism for linux/unix based on unix.Flock.

Documentation

Overview

Package flock provides a simple file locking mechanism for linux/unix based on unix.Flock.

Index

Constants

This section is empty.

Variables

View Source
var ErrWouldBlock = errors.New("would block")

ErrWouldBlock is returned by the non-blocking locks when it would have blocked.

Functions

This section is empty.

Types

type Flock

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

Flock is a file based lock mechanism.

func New

func New(name string) (*Flock, error)

New creates a new Flock for the given path name.

func (*Flock) Close

func (f *Flock) Close() error

Close closes the open file. This should be called when the lock is no longer needed.

func (*Flock) LockExclusive

func (f *Flock) LockExclusive() error

LockExclusive attempts to get an exclusive lock but won't block if it can't be immediately acquired. In this case, the return error is ErrWouldBlock.

func (*Flock) LockExclusiveWait

func (f *Flock) LockExclusiveWait() error

LockExclusiveWait attempts to get an exclusive lock and waits until that lock is acquired or an error occurs.

func (*Flock) LockShared

func (f *Flock) LockShared() error

LockShared attempts to get a shared lock but won't block if it can't be immediately acquired. In this case, the return error is ErrWouldBlock.

func (*Flock) LockSharedWait

func (f *Flock) LockSharedWait() error

LockSharedWait attempts to get a shared lock and waits until that lock is acquired or an error occurs.

func (*Flock) Unlock

func (f *Flock) Unlock() error

Unlock attempts to release the lock you have

Jump to

Keyboard shortcuts

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