hopr_async_runtime/
lib.rs1#[cfg(feature = "runtime-async-std")]
6pub mod prelude {
7 pub use async_std::future::timeout as timeout_fut;
8 pub use async_std::task::{sleep, spawn, spawn_blocking, spawn_local, JoinHandle};
9
10 pub async fn cancel_join_handle<T>(handle: JoinHandle<T>) {
11 handle.cancel().await;
12 }
13}
14
15#[cfg(all(feature = "runtime-tokio", not(feature = "runtime-async-std")))]
18pub mod prelude {
19 pub use tokio::time::timeout as timeout_fut;
20 pub use tokio::{
21 task::{spawn, spawn_blocking, spawn_local, JoinHandle},
22 time::sleep,
23 };
24
25 pub async fn cancel_join_handle<T>(handle: JoinHandle<T>) {
26 handle.abort()
27 }
28}
29
30#[cfg(all(not(feature = "runtime-tokio"), not(feature = "runtime-async-std")))]
32compile_error!("No runtime enabled");