#![allow(async_fn_in_trait)]
mod runtime;
mod task;
pub use runtime::Runtime;
pub use task::{JoinError, JoinHandle, spawn, spawn_local};
#[cfg(not(target_arch = "wasm32"))]
pub use tokio::time::error::Elapsed;
#[cfg(target_arch = "wasm32")]
pub use wasmtimer::tokio::error::Elapsed;
pub async fn sleep(duration: std::time::Duration) {
#[cfg(not(target_arch = "wasm32"))]
tokio::time::sleep(duration).await;
#[cfg(target_arch = "wasm32")]
wasmtimer::tokio::sleep(duration).await;
}
pub async fn timeout<F: std::future::Future>(
duration: std::time::Duration,
future: F,
) -> Result<F::Output, Elapsed> {
#[cfg(not(target_arch = "wasm32"))]
{
tokio::time::timeout(duration, future).await
}
#[cfg(target_arch = "wasm32")]
{
wasmtimer::tokio::timeout(duration, future).await
}
}