Skip to main content

wait_release

Function wait_release 

Source
pub(crate) async fn wait_release(
    release: Option<Release>,
    cancel: &CancellationToken,
)
Expand description

Resolve when the head unit may be written, or when the session is torn down — whichever comes first.

Races three level-triggered tokens: the wheel’s deadline, the unit’s Hold gate (a released gate makes a unit due early — see Pending::is_due) and session cancellation. It registers nothing: every one of the three is a CancellationToken, so creating and dropping the futures on each select! iteration is free of lost-wakeup races.

None parks until cancellation. Callers guard the branch with if head_release.is_some(), so that path is a safety net rather than a normal outcome: it must not resolve immediately, or a caller that forgot the guard would spin the loop hot on an empty queue.