Form changes

This commit is contained in:
François Autin 2023-03-22 16:21:15 +01:00
parent caddc445b8
commit df7c0af62b
No known key found for this signature in database
GPG Key ID: 343F5D382E1DD77C

View File

@ -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);