tsuki_scheduler/async_scheduler/
async_std.rs1use crate::{AsyncSchedulerRunner, prelude::AsyncRuntime, runtime::AsyncStd};
2
3impl AsyncRuntime for AsyncStd {
4 fn wake_after(&self, duration: std::time::Duration, ctx: &mut std::task::Context<'_>) {
5 let waker = ctx.waker().clone();
6 async_std::task::spawn(async move {
7 async_std::task::sleep(duration).await;
8 waker.wake()
9 });
10 }
11 fn spawn<F>(task: F) -> Self::Handle
12 where
13 F: std::future::Future<Output = ()> + Send + 'static,
14 {
15 async_std::task::spawn(task)
16 }
17}
18
19impl AsyncSchedulerRunner<AsyncStd> {
20 pub fn async_std() -> Self {
21 Self::default()
22 }
23}