lock

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package lock provides an advisory file lock around the critical section that mutates tasks.txt (SPEC §6.4). It locks a dedicated lock file — never tasks.txt itself — so the atomic rename that replaces tasks.txt can't swap the inode out from under a held lock.

flock(2) is local-filesystem only; on NFS it may silently no-op. The store is documented as local-FS only for concurrent access.

Index

Constants

View Source
const DefaultTimeout = 2 * time.Second

DefaultTimeout bounds how long Acquire waits before reporting the store busy.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handle

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

Handle is a held lock. Release must be called (typically via defer).

func Acquire

func Acquire(path string, timeout time.Duration) (*Handle, error)

Acquire takes an exclusive advisory lock on path, waiting up to timeout. It returns a clear "store is busy" error rather than blocking forever or silently succeeding.

func (*Handle) Release

func (h *Handle) Release() error

Release unlocks and closes the lock file.

Jump to

Keyboard shortcuts

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