Skip to main content

track_background_task

Function track_background_task 

Source
pub fn track_background_task<F>(fut: F)
where F: Future<Output = ()> + Send + 'static,
Expand description

Spawn a fire-and-forget background task that daemon shutdown’s drain() waits for, instead of a bare tokio::spawn that a SIGTERM can abort mid-flight with no trace. Only the enqueue (an atomic increment) is synchronous on the caller’s path — the future itself still runs fully off-path, unawaited. The decrement happens via BackgroundTaskGuard’s Drop, so a panic inside fut still restores the count.