tsuki_scheduler/runtime/
async_std.rs1use std::future::Future;
2
3use crate::schedule::IntoSchedule;
4use crate::{Runtime, Task};
5
6use async_std::task::JoinHandle;
7
8#[derive(Debug, Default)]
15pub struct AsyncStd;
16
17impl Runtime for AsyncStd {
18 type Handle = JoinHandle<()>;
19}
20
21impl AsyncStd {
22 pub fn new() -> Self {
23 Self
24 }
25}
26
27impl Task<AsyncStd> {
28 pub fn async_std<S, F, Fut>(schedule: S, task: F) -> Self
38 where
39 S: IntoSchedule,
40 S::Output: Send + 'static,
41 F: Fn() -> Fut + Send + 'static,
42 Fut: Future<Output = ()> + Send + 'static,
43 {
44 Task {
45 schedule: Box::new(schedule.into_schedule()),
46 run: Box::new(move |_: _, _: _| async_std::task::spawn(task())),
47 }
48 }
49}