Skip to content

Commit

Permalink
Organize code
Browse files Browse the repository at this point in the history
  • Loading branch information
temeddix committed Sep 14, 2024
1 parent d1ac5f0 commit c4b49d9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions rust_crate/src/shutdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,21 @@ impl EventBlocking {
}

pub fn wait(&self) {
let mut guard;
// Lock the inner state
guard = match self.inner.lock() {
// Lock the inner state and wait on the condition variable
let mut guard = match self.inner.lock() {
Ok(inner) => inner,
Err(poisoned) => poisoned.into_inner(),
};
loop {
// Check if the condition is met
if guard.flag || guard.session != self.started_session {
break;
}
// Wait on the condition variable and reassign the guard
guard = match self.condvar.wait(guard) {
Ok(inner) => inner,
Err(poisoned) => poisoned.into_inner(),
};
// Check if the condition is met
if guard.flag || guard.session != self.started_session {
break;
}
}
}
}
Expand Down

0 comments on commit c4b49d9

Please sign in to comment.