Trait sans_io_runtime::TaskSwitcherChild

source ·
pub trait TaskSwitcherChild<Out> {
    type Time: Copy;

    // Required method
    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);

Required Associated Types§

Required Methods§

source

fn pop_output(&mut self, now: Self::Time) -> Option<Out>

Implementors§

source§

impl<In, Out, T: Task<In, Out>, const STACK_SIZE: usize> TaskSwitcherChild<(usize, Out)> for TaskGroup<In, Out, T, STACK_SIZE>

§

type Time = <T as TaskSwitcherChild<Out>>::Time