1
0
forked from Rativel/BurritOS

Changed all reference to thread with an RefCell to enforce mutability

This commit is contained in:
Quentin Legot
2023-03-09 14:00:42 +01:00
committed by François Autin
parent a1713e0373
commit 45fea708fc
6 changed files with 62 additions and 60 deletions

View File

@@ -1,3 +1,4 @@
use std::cell::RefCell;
use std::rc::Rc;
use crate::utility::list::List;
@@ -7,7 +8,7 @@ use super::system::System;
#[derive(PartialEq)]
pub struct Scheduler {
ready_list: List<Rc<Thread>>
ready_list: List<Rc<RefCell<Thread>>>
}
impl Scheduler {
@@ -28,7 +29,7 @@ impl Scheduler {
/// ## Pamameter
///
/// **thread** is the thread to be put on the read list
pub fn ready_to_run(&mut self, thread: Rc<Thread>) {
pub fn ready_to_run(&mut self, thread: Rc<RefCell<Thread>>) {
self.ready_list.push(thread);
}
@@ -38,7 +39,7 @@ impl Scheduler {
/// Thread is removed from the ready list.
///
/// **return** Thread thread to be scheduled
pub fn find_next_to_run(&mut self) -> Option<Rc<Thread>> {
pub fn find_next_to_run(&mut self) -> Option<Rc<RefCell<Thread>>> {
self.ready_list.pop()
}