Skip to content

Commit

Permalink
multicore: Unconditionally panic if Waiter::wait is called from threa…
Browse files Browse the repository at this point in the history
…dpool


This occurring is a programming error.

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
  • Loading branch information
str4d and daira committed Jun 4, 2021
1 parent 6e9f575 commit 22caab9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/multicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ mod implementation {
/// Wait for the result.
pub fn wait(&self) -> T {
if THREAD_POOL.current_thread_index().is_some() {
// Calling `wait()` from within the worker thread pool can lead to dead logs
error!("The wait call should never be done inside the worker thread pool");
debug_assert!(false);
let msg = "wait() cannot be called from within the worker thread pool since that would lead to deadlocks";
// panic! doesn't necessarily kill the process, so we log as well.
error!("{}", msg);
panic!("{}", msg);
}
self.receiver.recv().unwrap()
}
Expand Down

0 comments on commit 22caab9

Please sign in to comment.