diff --git a/src/runtime2/scheduler.rs b/src/runtime2/scheduler.rs index bf620950f3942fc085ebf3d4db60f089afd0f2ae..1bcdcbc7ab628629a8cb5a46bbc1a57d553e59f3 100644 --- a/src/runtime2/scheduler.rs +++ b/src/runtime2/scheduler.rs @@ -14,6 +14,14 @@ pub(crate) struct SchedulerCtx<'a> { pub runtime: &'a Runtime, } +impl<'a> SchedulerCtx<'a> { + pub fn new(runtime: &'a Runtime) -> Self { + return Self { + runtime, + } + } +} + impl Scheduler { // public interface to thread @@ -22,7 +30,7 @@ impl Scheduler { } pub fn run(&mut self) { - let scheduler_ctx = SchedulerCtx{ runtime: &*self.runtime }; + let mut scheduler_ctx = SchedulerCtx::new(&*self.runtime); 'run_loop: loop { // Wait until we have something to do (or need to quit) @@ -39,7 +47,7 @@ impl Scheduler { // be re-executed immediately. let mut new_scheduling = CompScheduling::Immediate; while let CompScheduling::Immediate = new_scheduling { - new_scheduling = component.code.run(&scheduler_ctx, &mut component.private.ctx).expect("TODO: Handle error"); + new_scheduling = component.code.run(&mut scheduler_ctx, &mut component.private.ctx).expect("TODO: Handle error"); } // Handle the new scheduling