flock

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flock

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

Flock represents a handle on a file which can then be locked and unlocked to provide cross-process synchronization and locking.

func New

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

New creates a new handle on a file. If the file does not exist then it is created. The parent directory must already exist before this is called.

func (*Flock) Lock

func (f *Flock) Lock() error

Lock exclusively locks the file. Subsequent calls will block until the original lock is released. It is safe to call this concurrently in both the current process and other processes.

func (*Flock) Unlock

func (f *Flock) Unlock() error

Unlock unlocks the file so that another waiting task can acquire the lock. This function will panic unlock is called on a lock which is already unlocked. It is not possible to unlock a lock from a different handle than locked it.

Jump to

Keyboard shortcuts

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