use crate::core::runtime::Runtime;
#[derive(Copy, Clone, Debug)]
pub struct RuntimeTokio;
#[async_trait::async_trait]
impl Runtime for RuntimeTokio {
fn spawn<R>(&self, future: impl futures::Future<Output = R> + Send + 'static)
where
R: Send + 'static,
{
tokio::spawn(future);
}
async fn sleep(self, delay: u64) {
tokio::time::sleep(tokio::time::Duration::from_secs(delay)).await
}
async fn sleep_microseconds(self, delay: u64) {
tokio::time::sleep(tokio::time::Duration::from_micros(delay)).await
}
}