diff --git a/ethcore/src/verification/queue/mod.rs b/ethcore/src/verification/queue/mod.rs index 0b39dd769..686a1d093 100644 --- a/ethcore/src/verification/queue/mod.rs +++ b/ethcore/src/verification/queue/mod.rs @@ -66,20 +66,20 @@ impl Default for Config { struct VerifierHandle { deleting: Arc, - sleep: Arc<(Mutex, Condvar)>, + sleep: Arc, thread: JoinHandle<()>, } impl VerifierHandle { // signal to the verifier thread that it should sleep. fn sleep(&self) { - *self.sleep.0.lock() = true; + self.sleep.store(true, AtomicOrdering::SeqCst); } // signal to the verifier thread that it should wake up. fn wake_up(&self) { - *self.sleep.0.lock() = false; - self.sleep.1.notify_all(); + self.sleep.store(false, AtomicOrdering::SeqCst); + self.thread.thread().unpark(); } // signal to the verifier thread that it should conclude its @@ -91,7 +91,7 @@ impl VerifierHandle { // join the verifier thread. fn join(self) { - self.thread.join().unwrap(); + self.thread.join().expect("Verifier thread panicked"); } } @@ -241,9 +241,9 @@ impl VerificationQueue { // enable only the first few verifiers. let sleep = if i < default_amount { - Arc::new((Mutex::new(false), Condvar::new())) + Arc::new(AtomicBool::new(false)) } else { - Arc::new((Mutex::new(true), Condvar::new())) + Arc::new(AtomicBool::new(true)) }; verifiers.push(VerifierHandle { @@ -283,14 +283,13 @@ impl VerificationQueue { ready: Arc, deleting: Arc, empty: Arc, - sleep: Arc<(Mutex, Condvar)>, + sleep: Arc, ) { while !deleting.load(AtomicOrdering::Acquire) { { - let mut should_sleep = sleep.0.lock(); - while *should_sleep { + while sleep.load(AtomicOrdering::SeqCst) { trace!(target: "verification", "Verifier sleeping"); - sleep.1.wait(&mut should_sleep); + ::std::thread::park(); trace!(target: "verification", "Verifier waking up"); if deleting.load(AtomicOrdering::Acquire) {