lock

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrByteRangeAcquired = errors.New("file byte-range lock is already acquired")

ErrByteRangeAcquired corresponds to the error returned when a file byte-range is already acquired.

View Source
var ErrLockNotSupported = errors.New("file lock is not supported")

ErrLockNotSupported corresponds to the error returned when file locking is not supported.

Functions

func Exclusive

func Exclusive(path string) (fd int, err error)

Exclusive applies an exclusive lock on path

func Release

func Release(fd int) error

Release removes a lock on path referenced by fd

func TryExclusive added in v1.3.0

func TryExclusive(path string) (fd int, accquired bool, err error)

TryExclusive applies an exclusive non-blocking lock on path

Types

type ByteRange

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

ByteRange defines a file byte-range lock.

func NewByteRange

func NewByteRange(fd int, start, len int64) *ByteRange

NewByteRange returns a file byte-range lock.

func (*ByteRange) Lock

func (r *ByteRange) Lock() error

Lock places a write lock for the corresponding byte-range.

func (*ByteRange) Lockw added in v1.3.0

func (r *ByteRange) Lockw() error

Lock places a write lock and waits for the corresponding byte-range.

func (*ByteRange) RLock

func (r *ByteRange) RLock() error

RLock places a read lock for the corresponding byte-range.

func (*ByteRange) RLockw added in v1.3.0

func (r *ByteRange) RLockw() error

RLock places a read lock and waits for the corresponding byte-range.

func (*ByteRange) Unlock

func (r *ByteRange) Unlock() error

Unlock removes the lock for the corresponding byte-range.

Jump to

Keyboard shortcuts

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