lock

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2017 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package locking provides simple Flock based file locking utilities designed for synchronization around files on a single system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exclusive

func Exclusive(file *os.File) error

Exclusive attempts to obtain an exclusive lock on the open file descriptor. This will block until the lock can be obtained.

func IsResourceUnavailable

func IsResourceUnavailable(err error) bool

IsResourceUnavailable is used on the errors returned by TryExclusive and TryShare to determine if the error means the lock could not be obtained. The above functions may return other errors, of course.

func Release

func Release(file *os.File) error

Release will release the currently held exclusive or shared lock on the given open file descriptor. Note that closing the file descriptor also releases locks currently held on it.

func Share

func Share(file *os.File) error

Share attempts to obtain a shared or read-only lock on the given open file descriptor. Multiple processes or file descriptors may hold shared locks on the same file. This will block until the lock can be obtained.

func TryExclusive

func TryExclusive(file *os.File) error

TryExclusive is the non-blocking form of Exclusive and will return an error if the lock could not be obtained immediately.

func TryShare

func TryShare(file *os.File) error

TryShare is the non-blocking form of Share and will return an error if the lock could not be obtained immediately.

Types

This section is empty.

Jump to

Keyboard shortcuts

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