From df7c0af62b2eaaac5c8efd6685d141a948bc4ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Autin?= Date: Wed, 22 Mar 2023 16:21:15 +0100 Subject: [PATCH] Form changes --- src/kernel/synch.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/kernel/synch.rs b/src/kernel/synch.rs index ebd18cb..aa96618 100644 --- a/src/kernel/synch.rs +++ b/src/kernel/synch.rs @@ -147,12 +147,12 @@ impl Lock { let old_status = machine.interrupt.set_status(InterruptOff); match thread_manager.get_g_current_thread() { - Some(thread) => { + Some(_) => { if self.held_by_current_thread(thread_manager) { - if self.waiting_queue.peek() != None { + if self.waiting_queue.peek().is_none() { self.owner = Some(self.waiting_queue.pop().unwrap()); match &self.owner { - Some(x) => thread_manager.ready_to_run(Rc::clone(&x)), + Some(x) => thread_manager.ready_to_run(Rc::clone(x)), None => () } } else { @@ -173,7 +173,7 @@ impl Lock { match &self.owner { Some(x) => match thread_manager.get_g_current_thread() { - Some(thread) => Rc::ptr_eq(&x, &thread), + Some(thread) => Rc::ptr_eq(x, thread), None => false } None => false @@ -229,7 +229,7 @@ impl Condition { pub fn signal(&mut self, machine: &mut Machine, thread_manager: &mut ThreadManager) { let old_status = machine.interrupt.set_status(InterruptOff); - if self.waiting_queue.peek() != None { + if self.waiting_queue.peek().is_none() { thread_manager.ready_to_run(self.waiting_queue.pop().unwrap()); } @@ -246,7 +246,7 @@ impl Condition { pub fn broadcast(&mut self, machine: &mut Machine, thread_manager: &mut ThreadManager) { let old_status = machine.interrupt.set_status(InterruptOff); - while self.waiting_queue.peek() != None { + while self.waiting_queue.peek().is_none() { thread_manager.ready_to_run(self.waiting_queue.pop().unwrap()); } machine.interrupt.set_status(old_status);