Expand description
Rename-published owner locks with dead-owner retirement and an unbounded wait.
What:
Rename-published owner-lock directories with process-birth ownership:
acquisition
with dead-owner retirement,
an unbounded wait while the owner lives,
and release by
rename before deletion.
Why:
The landing,
reservation,
hook,
capture and push locks all work this way in the
incumbent (src/owner-lock/owner-lock.ts) and in its hook dispatcher,
and both
wrappers contend on the same directories while both are installed.
A published lock
always names its owner because its candidate is complete before the rename.
In TS you’d write (pseudocode):
await using lock = await acquireOwnerLock({ lockDirectory });Structs§
- Owner
Lock - What:
A held owner lock.
Releasing it proves the lock still names this holder first.
Dropping an unreleased lock releases it and ignores a failure.
Why:
An early return or an unwinding error must not leave a live-looking lock behind;
an explicit
releasereports a changed owner. - Silent
Wait - What: The notice that says nothing. Why: Most acquirers wait silently, as the incumbent’s default.
Enums§
- Owner
Lock Error - What: Why an owner-lock operation failed. Why: Each failure stops the caller with the lock named; none is a reason to delete a lock that might belong to a live owner.
Constants§
- DEFAULT_
POLL_ DELAY - Delay between acquisition attempts while a live owner holds the lock.
Traits§
- Wait
Notice - What:
Something told once that an acquirer has to wait,
such as a stderr notice.
A
traitis an interface a type implements. Why: A waiter may tell the user whose lock it waits for; the lock module stays silent.
Functions§
- acquire_
owner_ lock - What:
Acquire a lock,
waiting without bound while a live owner holds it.
noticeis told once, when the first attempt finds the lock busy;&mut dyn WaitNoticelends any value implementing that interface. Why: The wait is unbounded by contract while the owner lives; a dead owner’s lock is retired on the next attempt. One process record is used for every attempt. - is_
occupied_ error - What:
Whether a rename failed because another directory already holds the name.
Why:
renameonto a non-empty directory fails withEEXISTorENOTEMPTYon Unix and with an access-denied error on Windows (Node’sEPERM); the incumbent’sisOccupiedErroraccepts exactly these. - retire_
lock_ of_ dead_ owner - What: Retire a lock whose recorded owner is dead; an absent lock or a live owner’s lock is left alone. Why: Recovery retires a dead reservation holder’s lock this way.
- try_
acquire_ owner_ lock - What:
One publication attempt without waiting.
Ok(None)means another owner holds the lock, or a dead owner’s lock was just retired and the caller should try again. Why: The reservation is taken this way, by a requester that re-checks its turn between attempts.