I am trying to pass the scheduler to a structure which will be used by a newly spawned thread. All of this needs to happen in a loop:
// Custom structure
struct CSlice<'a> {
scheduler: &'a mut StandaloneScheduler
}
impl<'a> CSlice<'a> {
fn start(self)
{
println!("Start slice");
unsafe {
control_nf(self.scheduler); // It gets passed on and on to different functions.
}
}
}
fn main() {
for i in 0..max_slices {
let mut sched = StandaloneScheduler::new();
let mut slice = CtrlSlice {
scheduler: &mut sched}; // Error (Temp value/ Cannot borrow here)
}
thread::spawn(move || slice.start());
}
}
What am I doing wrong? I tried cloning but Scheduler
does not implement Clone
. I know that the reference goes out of scope while passing it to the function but I'm not sure how to fix it.