From 5c66577989c912be429b0212b8b3033fa8eba060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Autin?= Date: Wed, 19 Apr 2023 23:38:58 +0200 Subject: [PATCH] Cleanup of clippy warnings --- src/kernel/thread_manager.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/kernel/thread_manager.rs b/src/kernel/thread_manager.rs index eb69172..9f64b84 100644 --- a/src/kernel/thread_manager.rs +++ b/src/kernel/thread_manager.rs @@ -37,7 +37,9 @@ pub struct ThreadManager { pub g_alive: List>>, /// Thread in ready state waiting to become active ready_list: List>>, + /// List of objects created by the thread manager (such as Locks and Semaphores) obj_addrs: ObjAddr, + /// If true, enables debug mode debug: bool } @@ -159,7 +161,7 @@ impl ThreadManager { /// Finish the execution of the thread and prepare its deallocation pub fn thread_finish(&mut self, machine: &mut Machine, thread: Rc>) { let old_status = machine.interrupt.set_status(InterruptStatus::InterruptOff); - assert_eq!(self.g_alive.remove(Rc::clone(&thread)), true); + assert!(self.g_alive.remove(Rc::clone(&thread))); self.debug(format!("Sleeping thread {}", thread.borrow().get_name())); // g_objets_addrs->removeObject(self.thread) // a ajouté plus tard self.thread_sleep(machine, Rc::clone(&thread)); @@ -233,9 +235,8 @@ impl ThreadManager { }; let old_status = machine.interrupt.set_status(InterruptStatus::InterruptOff); sema.counter += 1; - match sema.waiting_queue.pop() { - Some(thread) => self.ready_to_run(thread), - None => () + if let Some(thread) = sema.waiting_queue.pop() { + self.ready_to_run(thread) } machine.interrupt.set_status(old_status); Ok(MachineOk::Ok) @@ -317,10 +318,12 @@ impl ThreadManager { self.g_current_thread = thread } + /// Returns a mutable reference to the ObjAddr field of this thread_manager pub fn get_obj_addrs(&mut self) -> &mut ObjAddr { &mut self.obj_addrs } + /// Prints debug messages if self.debug is set to true. fn debug(&self, message: String) { if self.debug { println!("{}", message);