Expand description
Atomic file publication primitives: lock-file guarded writes published by rename.
Consolidates the hand-rolled create_new(temp) + optional barrier +
rename(target) dances scattered across writers. The LockFile guard
owns the exclusive-create temp/lock file and removes it on drop unless the
write is explicitly persisted (or deliberately kept, for mkstemp-style
creators whose temporary name is the deliverable).
Naming conventions stay at call sites: LockFile::acquire uses git’s
sibling <name>.lock convention, while LockFile::create accepts an
exact path for load-bearing names such as odb tmp_obj_<pid>_<n> temps.
Structs§
- Lock
File - An exclusively created lock/temp file with atomic publication semantics.
Functions§
- atomic_
write - Atomically replace
pathwithcontents: sibling.locktemp, write, rename. Fails when the lock already exists; callers create parent directories themselves when needed. - atomic_
write_ with - Atomically replace
pathusing a writer callback, so streamed encoders avoid buffering the whole payload twice. - lock_
path_ for - Lock path for
path: the file name suffixed.lockin the same directory (git’s lockfile convention, e.g.packed-refs->packed-refs.lock).