pub struct Turn { /* private fields */ }Expand description
One thread’s turn at a lock path within this process; the next waiter in line gets it when this drops.
An advisory file lock polled with a deadline is no queue: threads of one
process that take the same lock back to back make a waiter’s deadline count
every critical section ahead of it, so eight writers whose writes each take
a second (an fsync plus a Windows replace that waits out a scanner) fail
the last one after five seconds although every holder made progress. The
turn queues the threads of a process in arrival order, and a waiter’s
timeout counts only time in which no turn was handed over: a holder that
never returns still fails every waiter after timeout, a queue that moves
fails nobody. Other processes are still bounded by the file lock itself.