pub fn block_flock_step<P: AsRef<Path>>(
path: P,
mode: FlockMode,
deadline: Instant,
tick: Duration,
) -> Result<FlockWait>Expand description
One deadline-bounded BLOCKING flock(2) cycle with a periodic
re-evaluation tick.
Parks the calling thread in the kernel’s per-inode flock wait queue — the wake-latency primitive the polling loops lacked: the kernel wakes the waiter at release time, so a freed lock is picked up in microseconds, not at the next poll interval.
Returns:
FlockWait::Grantedwhen the lock is granted,FlockWait::Tickwhentickelapses first (caller re-evaluates live state — e.g. a coordinator re-scanning for a fully-free alternative target — then typically calls again),FlockWait::DeadlineExpiredwhendeadlinepasses,Erron open / unexpected-errno failures.
Mechanism: a thread-targeted CLOCK_MONOTONIC POSIX timer
(DeadlineTimer) delivers SIGRTMIN+4 (no-op handler, no
SA_RESTART) to this thread every tick (clamped to the
remaining deadline budget), forcing the blocked flock to return
EINTR; the step maps that to Tick or DeadlineExpired by the
clock. The interval re-fire means a signal landing in the gap
between arming and blocking cannot strand the waiter.