Small fix with not matching types

This commit is contained in:
Rémi Rativel 2023-03-14 16:44:10 +01:00
parent 5b8abd2a07
commit ba895e3587

View File

@ -24,6 +24,11 @@ pub struct Semaphore {
impl Semaphore { impl Semaphore {
/// Initializes a semaphore, so that it can be used for synchronization.
///
/// ### Parameters
/// - *counter* initial value of counter
/// - *thread_manager* Thread manager which managing threads
pub fn new(counter: i32, thread_manager: Rc<RefCell<ThreadManager>>) -> Semaphore{ pub fn new(counter: i32, thread_manager: Rc<RefCell<ThreadManager>>) -> Semaphore{
Semaphore { counter, waiting_queue: List::new(), thread_manager} Semaphore { counter, waiting_queue: List::new(), thread_manager}
} }
@ -153,7 +158,10 @@ impl Lock {
} }
pub fn held_by_current_thread(&mut self, current_thread: Rc<RefCell<Thread>>) -> bool { pub fn held_by_current_thread(&mut self, current_thread: Rc<RefCell<Thread>>) -> bool {
Rc::ptr_eq(&self.owner, &current_thread) match &self.owner {
Some(x) => Rc::ptr_eq(&x, &current_thread),
None => false
}
} }
} }