filelock

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 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 Mutex

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

Mutex is a file-based mutex intended to facilitate cross-process synchronization. Locks acquired by Mutex are advisory, so all participating processes must use advisory lock features in order to co-operate. Locks acquired by Mutex are not inherited by child processes and are automatically released when the process exits.

It is not intended for in-process synchronization, and should not be shared between goroutines without being appropriately guarded by a sync.Mutex.

func MutexAt

func MutexAt(path string) *Mutex

MutexAt returns a new Mutex instance that will use the given path as the lock file.

func (*Mutex) Lock

func (m *Mutex) Lock() error

Lock attempts to lock the file for reading & writing. It blocks until the lock is acquired, or an error happens. If the file is already locked for reading, it will upgrade the lock to a read-write lock.

func (*Mutex) RLock

func (m *Mutex) RLock() error

RLock attempts to lock the file for reading. It blocks until the lock is acquired, or an error happens. If the file is already locked for writing, it will downgrade the lock to a read-only lock.

func (*Mutex) Unlock

func (m *Mutex) Unlock() error

Unlock releases any lock acquired on the file.

Jump to

Keyboard shortcuts

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