use crate::asm::data::literal::Value; use std::time::Duration; /// Cycles spent executing an instruction pub type CyclesSpent = usize; /// Result of execution evaluation (when Fault is not generated) #[derive(Debug)] pub struct EvalRes { pub cycles: CyclesSpent, pub advance: i64, pub sched: SchedSignal, } impl Default for EvalRes { fn default() -> Self { Self { cycles: 1, advance: 1, sched: SchedSignal::Normal, } } } /// Signal to the scheduler #[derive(Debug)] pub enum SchedSignal { /// No signal, execution went normally. Normal, /// Yield control, optionally with a value. /// If a value is yielded, it must be consumed through the handle before execution can resume. Yield(Option), /// The routine requests a delay in execution. The actual sleep time can be longer due to task /// switching overhead. Sleep(Duration), /// Return from a coroutine - the thread ends and should be joined. Ret(Vec), /// Request to join a coroutine/thread Join(Value), }