lock

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lock

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

Lock uses a file lock to coordinate access to resources shared with other processes. Callers are responsible for preventing races within a process. Lock applies advisory locks on Linux and macOS and is therefore unreliable on these platforms when several processes concurrently try to acquire the lock.

func New

func New(p string, retryDelay time.Duration) (*Lock, error)

New is the constructor for Lock. "p" is the path to the lock file.

func (*Lock) Lock

func (l *Lock) Lock(ctx context.Context) error

Lock acquires the file lock on behalf of the process. The behavior of concurrent and repeated calls is undefined. For example, Linux may or may not allow goroutines scheduled on different threads to hold the lock simultaneously.

func (*Lock) Unlock

func (l *Lock) Unlock() error

Unlock releases the lock and deletes the lock file.

Jump to

Keyboard shortcuts

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