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::{Handle, Runtime, RuntimeFlavor},
8    task::{
9        block_in_place, id as task_id, spawn, spawn_blocking, unconstrained, yield_now, JoinHandle,
10    },
11    time::{sleep, timeout},
12};
13pub use tokio_stream::wrappers::{BroadcastStream, UnboundedReceiverStream as ReceiverStream};
14pub use tokio_util::sync::CancellationToken;
15
16/// Returns a future that completes when Ctrl+C is received.
17///
18/// This is a thin wrapper around `tokio::signal::ctrl_c()` that panics on error.
19///
20/// # Example
21///
22/// ```ignore
23/// send_message_on(handle.clone(), rt::ctrl_c(), Msg::Shutdown);
24/// ```
25pub async fn ctrl_c() {
26    tokio::signal::ctrl_c()
27        .await
28        .expect("Failed to listen for Ctrl+C");
29}