sans_io_runtime/task.rs
1use std::time::Instant;
2
3use crate::TaskSwitcherChild;
4
5pub mod group;
6pub mod switcher;
7
8/// Represents a task.
9pub trait Task<In, Out>: TaskSwitcherChild<Out> {
10 /// Called each time the task is ticked. Default is 1ms.
11 fn on_tick(&mut self, now: Instant);
12
13 /// Called when an input event is received for the task.
14 fn on_event(&mut self, now: Instant, input: In);
15
16 /// Gracefully shuts down the task.
17 fn on_shutdown(&mut self, now: Instant);
18}