flock

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 5 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 provides in-process (channel) + cross-process (flock) mutual exclusion.

func New

func New(path string) *Lock

New creates a Lock for the given path.

func (*Lock) Lock

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

Lock acquires the lock, blocking until available or ctx is canceled.

func (*Lock) TryLock

func (l *Lock) TryLock(_ context.Context) (bool, error)

TryLock attempts a non-blocking acquisition. Returns (false, nil) if the lock is currently held by another caller.

func (*Lock) Unlock

func (l *Lock) Unlock(_ context.Context) error

Unlock releases the lock.

Jump to

Keyboard shortcuts

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