pub struct NotificationDrain(/* private fields */);Expand description
A session-scoped registry of in-flight detached notify task handles
(Finding 1 fix, the Critical review caught in the real CLI): notify
pushes the JoinHandle it spawns here instead of discarding it, so a
caller that’s about to tear down its runtime — the one-shot CLI’s
current_thread block_on, which drops the instant its driving future
resolves — can drain them first, under a short bounded grace period.
Without this, a detached tokio::spawn awaiting a real subprocess (a
notification shell hook) is silently killed mid-flight the moment
block_on returns: nothing else is left polling it, unlike the
long-lived TUI/interactive path (or a #[tokio::test] that keeps polling
events.recv() in a loop) where the runtime stays alive on its own.
Cloning shares the same underlying registry (an Arc), so notify’s
caller (the actor/turn) and the CLI’s exit-time drain call see the same
set of handles.
Implementations§
Source§impl NotificationDrain
impl NotificationDrain
pub fn new() -> Self
Sourcepub async fn drain(&self, grace: Duration)
pub async fn drain(&self, grace: Duration)
Await every still-pending handle, bounded by grace — never longer.
A handle that hasn’t finished when grace elapses is abandoned
(best-effort, exactly like the per-hook timeout itself): this never
blocks the caller past grace, so a hung notifier can’t wedge the
process’s exit either.
Trait Implementations§
Source§impl Clone for NotificationDrain
impl Clone for NotificationDrain
Source§fn clone(&self) -> NotificationDrain
fn clone(&self) -> NotificationDrain
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more