lock

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package lock provides interprocess locking using a combination of flock and process-local mutex-es

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InterProcessLock

type InterProcessLock struct {
	Path string
	// contains filtered or unexported fields
}

InterProcessLock provides a mutex that works across the current process and across all other processes. It works by first acquiring a local lock and then a file lock.

The reason that a local process lock is used first, is due to the limits of interprocess locking in Linux -> we have to avoid reusing the same lock file multiple times in the same process or closing one of the locks will unlock all the others. See: http://0pointer.de/blog/projects/locking.html

func (*InterProcessLock) Lock

func (l *InterProcessLock) Lock() error

Lock the lock, blocking until the lock has been acquired

func (*InterProcessLock) MustLock

func (l *InterProcessLock) MustLock()

MustLock engages the lock and panics if that fails (it will still block if the lock is already locked, since that is not an error)

func (*InterProcessLock) MustUnlock

func (l *InterProcessLock) MustUnlock()

MustUnlock removes the lock and panics if that fails

func (*InterProcessLock) Unlock

func (l *InterProcessLock) Unlock() error

Unlock the lock

Jump to

Keyboard shortcuts

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