Cleanup of clippy warnings

This commit is contained in:
François Autin 2023-04-19 23:38:58 +02:00
parent fe519555cc
commit 5c66577989
No known key found for this signature in database
GPG Key ID: 343F5D382E1DD77C

View File

@ -37,7 +37,9 @@ pub struct ThreadManager {
pub g_alive: List<Rc<RefCell<Thread>>>,
/// Thread in ready state waiting to become active
ready_list: List<Rc<RefCell<Thread>>>,
/// 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<RefCell<Thread>>) {
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);