]>
git.proxmox.com Git - rustc.git/blob - vendor/salsa/tests/parallel/signal.rs
1 use parking_lot
::{Condvar, Mutex}
;
4 pub(crate) struct Signal
{
10 pub(crate) fn signal(&self, stage
: usize) {
11 log
::debug
!("signal({})", stage
);
13 // This check avoids acquiring the lock for things that will
14 // clearly be a no-op. Not *necessary* but helps to ensure we
15 // are more likely to encounter weird race conditions;
16 // otherwise calls to `sum` will tend to be unnecessarily
19 let mut v
= self.value
.lock();
22 self.cond_var
.notify_all();
27 /// Waits until the given condition is true; the fn is invoked
28 /// with the current stage.
29 pub(crate) fn wait_for(&self, stage
: usize) {
30 log
::debug
!("wait_for({})", stage
);
32 // As above, avoid lock if clearly a no-op.
34 let mut v
= self.value
.lock();
36 self.cond_var
.wait(&mut v
);