storelock

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package storelock serializes writers of an on-disk store (the owner's book, a memory directory) across goroutines and processes.

The lock file is a sibling of the store, never inside it: a store directory can be replaced wholesale (book-tidy moves the whole book), and two writers holding locks on two different inodes would no longer exclude each other.

Index

Constants

View Source
const Supported = true

Supported reports whether Lock really excludes other writers.

Variables

This section is empty.

Functions

func Lock

func Lock(dir string) (*os.File, error)

Lock takes the exclusive lock of dir and returns the open lock file; closing it releases the lock. The file is returned (not an io.Closer) so a caller can hand the descriptor to a child process that must keep the lock held while it runs: a flock belongs to the open file description, not to the process.

flock does not nest within a process either: a second Lock on the same store from the same goroutine blocks forever, so a holder writes the store directly.

func Path

func Path(dir string) string

Path is the lock file that guards dir: "<parent>/.<base>.lock".

func TryLock

func TryLock(dir string) (f *os.File, ok bool, err error)

TryLock is Lock without waiting: ok is false when another holder has it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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