pub trait TaskSwitcherChild<Out> {
type Time: Copy;
// Required methods
fn empty_event(&self) -> Out;
fn is_empty(&self) -> bool;
fn pop_output(&mut self, now: Self::Time) -> Option<Out>;
}Expand description
Task group outputs state This is used for jumping between multi groups of tasks For example, we have two group G1 and G2, Each cycle we need to call G1.output until it returns None, then we call G2.output until it returns None, then we will have this cycle is finished Then we will start a new cycle and it loop like that
use std::time::Instant;
use sans_io_runtime::TaskSwitcher;
// This will create a task switcher with 2 tasks, use 2 bytes, we can adjust max to 16 tasks
let mut switcher = TaskSwitcher::new(2);
//we need to pop task index from wait queue
switcher.flag_task(0 as usize);
assert_eq!(switcher.current(), Some(0));
switcher.finished(0 as usize);
assert_eq!(switcher.current(), None);