Skip to content

Instantly share code, notes, and snippets.

/// This module contains helpers for managing lifetime of async functions.
/// In particular, it wraps the following two things from tokio:
/// * cancellation token to notify "async functions/actors" that they have to stop and
/// * tokio::sync::mpsc::Sender object (when it is dropped, parent knows that all its "children" has stopped)
/// We use a channel to wait until all children has died (likely, because cancellation_token had told them)
/// See more at https://tokio.rs/tokio/topics/shutdown
/// Usage:
/// ```