Try to fix deadlock in parallel mode
This commit is contained in:
parent
798fdfe24c
commit
129f1e6f76
1 changed files with 4 additions and 1 deletions
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue