tsuki_scheduler/runtime/
local.rs1use crate::schedule::IntoSchedule;
2use crate::{Runtime, Task};
3
4#[derive(Debug, Clone, Default)]
6pub struct Local;
7
8impl Local {
9 pub fn new() -> Self {
10 Local
11 }
12}
13
14impl Runtime for Local {
15 type Handle = ();
16}
17
18impl Task<Local> {
19 pub fn local<S, F>(schedule: S, task: F) -> Self
20 where
21 S: IntoSchedule,
22 S::Output: Send + 'static,
23 F: Fn() + Send + 'static + Clone,
24 {
25 Task {
26 schedule: Box::new(schedule.into_schedule()),
27 run: Box::new(move |_: _, _: _| (task)()),
28 }
29 }
30}