Skip to main content

release_dead_dispatch_holder

Function release_dead_dispatch_holder 

Source
pub fn release_dead_dispatch_holder(frame: usize) -> bool
Expand description

Release the dispatch guard on behalf of a holder that will never run again, and only while frame (from dispatch_holder_frame) still holds it. Returns whether it did.

Call it ONLY for a holder that is dead or about to be aborted, from the handler that knows it: the guard exists to keep two callers out of the sinks at once, and releasing a live holder’s breaks exactly that. A dead holder can no longer be in a sink, so the next record claims the guard, is delivered, and delivers what was held meanwhile.

What the holder was doing is lost with it: the record it was delivering, and, if it died while draining, the one held slot it had taken (held records then occupy one slot fewer until reboot). A sink it died inside sees its next call without the end of that one, so a sink that takes a lock a dead thread can own may block where it would otherwise have been skipped. The alternative, keeping the guard, loses EVERY later record.

A holder that died delivering a held record to a re-entrant sink had spent the whole re-entrant depth on it; that is given back too. A thread that dies inside a re-entrant sink’s DIRECT delivery holds no guard, so nothing here can see it: it keeps one unit of REENTRANT_DEPTH until reboot, and once that many have died, records take the guarded path for every sink (delivered, one at a time).