diff --git a/src/runtime2/scheduler.rs b/src/runtime2/scheduler.rs index 1e02cfa0db92610c63a8e2ac8800acd22fcd9ae3..b27cf5d06aa3b7636674263fd866508504b4317a 100644 --- a/src/runtime2/scheduler.rs +++ b/src/runtime2/scheduler.rs @@ -8,42 +8,49 @@ use super::runtime::*; pub(crate) struct Scheduler { runtime: Arc, scheduler_id: u32, + debug_logging: bool, } pub(crate) struct SchedulerCtx<'a> { pub runtime: &'a RuntimeInner, pub id: u32, pub comp: u32, + pub logging_enabled: bool, } impl<'a> SchedulerCtx<'a> { - pub fn new(runtime: &'a RuntimeInner, id: u32) -> Self { + pub fn new(runtime: &'a RuntimeInner, id: u32, logging_enabled: bool) -> Self { return Self { runtime, id, comp: 0, + logging_enabled, } } pub(crate) fn log(&self, text: &str) { - println!("[s:{:02}, c:{:03}] {}", self.id, self.comp, text); + if self.logging_enabled { + println!("[s:{:02}, c:{:03}] {}", self.id, self.comp, text); + } } // TODO: Obviously remove, but useful for testing pub(crate) fn log_special(&self, text: &str) { - println!("[s:{:02}, c:{:03}] *** *** {}", self.id, self.comp, text); + if self.logging_enabled { + println!("[s:{:02}, c:{:03}] *** *** {}", self.id, self.comp, text); + } } } impl Scheduler { // public interface to thread - pub fn new(runtime: Arc, scheduler_id: u32) -> Self { - return Scheduler{ runtime, scheduler_id } + pub fn new(runtime: Arc, scheduler_id: u32, debug_logging: bool) -> Self { + return Scheduler{ runtime, scheduler_id, debug_logging } } pub fn run(&mut self) { - let mut scheduler_ctx = SchedulerCtx::new(&*self.runtime, self.scheduler_id); + let mut scheduler_ctx = SchedulerCtx::new(&*self.runtime, self.scheduler_id, self.debug_logging); 'run_loop: loop { // Wait until we have something to do (or need to quit)