Skip to content

Commit

Permalink
Try to fix deadlock in parallel mode
Browse files Browse the repository at this point in the history
  • Loading branch information
andrews05 authored and shssoichiro committed Jun 25, 2023
1 parent 798fdfe commit 129f1e6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/evaluate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ impl Evaluator {
#[cfg(feature = "parallel")]
pub fn get_best_candidate(self) -> Option<Candidate> {
let (eval_send, eval_recv) = self.eval_channel;
drop(eval_send); // disconnect the sender, breaking the loop in the thread
// Disconnect the sender, breaking the loop in the thread
drop(eval_send);
// Yield to ensure evaluations are finished - this can prevent deadlocks when run within an existing thread pool
while let Some(rayon::Yield::Executed) = rayon::yield_local() {}
eval_recv.into_iter().min_by_key(Candidate::cmp_key)
}

Expand Down

0 comments on commit 129f1e6

Please sign in to comment.