1
+ #![ allow( unused) ]
2
+
1
3
use super :: sync:: { Condvar , Mutex } ;
2
4
3
5
#[ derive( Default ) ]
@@ -8,28 +10,36 @@ pub(crate) struct Signal {
8
10
9
11
impl Signal {
10
12
pub ( crate ) fn signal ( & self , stage : usize ) {
11
- // This check avoids acquiring the lock for things that will
12
- // clearly be a no-op. Not *necessary* but helps to ensure we
13
- // are more likely to encounter weird race conditions;
14
- // otherwise calls to `sum` will tend to be unnecessarily
15
- // synchronous.
16
- if stage > 0 {
17
- let mut v = self . value . lock ( ) . unwrap ( ) ;
18
- if stage > * v {
19
- * v = stage;
20
- self . cond_var . notify_all ( ) ;
13
+ // When running with shuttle we want to explore all possible
14
+ // executions, so we avoid signals entirely.
15
+ #[ cfg( not( feature = "shuttle" ) ) ]
16
+ {
17
+ // This check avoids acquiring the lock for things that will
18
+ // clearly be a no-op. Not *necessary* but helps to ensure we
19
+ // are more likely to encounter weird race conditions;
20
+ // otherwise calls to `sum` will tend to be unnecessarily
21
+ // synchronous.
22
+ if stage > 0 {
23
+ let mut v = self . value . lock ( ) . unwrap ( ) ;
24
+ if stage > * v {
25
+ * v = stage;
26
+ self . cond_var . notify_all ( ) ;
27
+ }
21
28
}
22
29
}
23
30
}
24
31
25
32
/// Waits until the given condition is true; the fn is invoked
26
33
/// with the current stage.
27
34
pub ( crate ) fn wait_for ( & self , stage : usize ) {
28
- // As above, avoid lock if clearly a no-op.
29
- if stage > 0 {
30
- let mut v = self . value . lock ( ) . unwrap ( ) ;
31
- while * v < stage {
32
- v = self . cond_var . wait ( v) . unwrap ( ) ;
35
+ #[ cfg( not( feature = "shuttle" ) ) ]
36
+ {
37
+ // As above, avoid lock if clearly a no-op.
38
+ if stage > 0 {
39
+ let mut v = self . value . lock ( ) . unwrap ( ) ;
40
+ while * v < stage {
41
+ v = self . cond_var . wait ( v) . unwrap ( ) ;
42
+ }
33
43
}
34
44
}
35
45
}
0 commit comments