lock

package
v0.0.0-...-7aa4b52 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package lock is a wrapper for file description locks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	*os.File
	// contains filtered or unexported fields
}

File is a flock() based avisory file lock.

dup()ed file descriptors share the same file description, and so share the same lock.

func Exclusive

func Exclusive(file *os.File) *File

Exclusive creates a new exclusive lock.

Returns an unlocked lock.

func OpenLockedExclusive

func OpenLockedExclusive(path string) (*File, error)

OpenLockedExclusive opens the given path and acquires an exclusive lock.

func OpenLockedShared

func OpenLockedShared(path string) (*File, error)

OpenShared opens the given path and acquires a shared lock.

func Shared

func Shared(file *os.File) *File

Shared creates a new shared lock.

The lock is implicitly released when the file description of file is closed.

Returns an unlocked lock.

func (*File) Lock

func (fl *File) Lock()

Lock implements sync.Locker.

It panics if the underlying syscalls return an error.

func (*File) TryLock

func (fl *File) TryLock() bool

TryLock attempts to lock the file without blocking.

It panics if the underlying syscalls return an error.

func (*File) Unlock

func (fl *File) Unlock()

Unlock implements sync.Locker.

It panics if the underlying syscalls return an error.

Jump to

Keyboard shortcuts

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