Skip to main content

spawned_rt/tasks/tokio/
mod.rs

1//! Tokio.rs reexports to prevent tokio dependencies within external code
2pub mod mpsc;
3pub mod oneshot;
4pub use tokio::sync::watch;
5
6pub use tokio::{
7    runtime::Runtime,
8    task::{id as task_id, spawn, spawn_blocking, JoinHandle},
9    time::{sleep, timeout},
10};
11pub use tokio_stream::wrappers::{BroadcastStream, UnboundedReceiverStream as ReceiverStream};
12pub use tokio_util::sync::CancellationToken;
13
14/// Returns a future that completes when Ctrl+C is received.
15///
16/// This is a thin wrapper around `tokio::signal::ctrl_c()` that panics on error.
17///
18/// # Example
19///
20/// ```ignore
21/// send_message_on(handle.clone(), rt::ctrl_c(), Msg::Shutdown);
22/// ```
23pub async fn ctrl_c() {
24    tokio::signal::ctrl_c()
25        .await
26        .expect("Failed to listen for Ctrl+C");
27}