Skip to main content

Crate harn_flock

Crate harn_flock 

Source
Expand description

Advisory file locks that cannot wait forever.

std::fs::File::lock has no timed form. A caller blocked on a lock nobody will release produces no error, no log line, and no stack — the process simply stops, and whatever supervises it can report only that it stopped. Recovering the reason means reproducing the wedge, and a rare interleaving can cost days of runner time to hit twice.

Every acquisition here carries a deadline and names the path it waited on, so a wedge surfaces as an error that says which lock and for how long.

The deadline is a diagnostic bound, not a coordination mechanism. Callers pick one from how long the critical section legitimately runs — schema initialization is milliseconds, a package install can be minutes — and set it far enough above that ceiling that expiry means something is wrong rather than merely slow.

Enums§

LockError
A lock that was not acquired.
LockMode
Whether a waiter needs the file to itself.

Functions§

lock_with_deadline
Take an advisory lock on file, giving up after timeout.