@@ -89,9 +89,10 @@ static CACHE: [Cache; 2] = [Cache::uninitialized(), Cache::uninitialized()];
89
89
/// Note: the last feature bit is used to represent an
90
90
/// uninitialized cache.
91
91
///
92
- /// Note: we use `Relaxed` atomic operations, because we are only interested
92
+ /// Note: we can use `Relaxed` atomic operations, because we are only interested
93
93
/// in the effects of operations on a single memory location. That is, we only
94
- /// need "modification order", and not the full-blown "happens before".
94
+ /// need "modification order", and not the full-blown "happens before". However,
95
+ /// we use `SeqCst` just to be on the safe side.
95
96
struct Cache ( AtomicUsize ) ;
96
97
97
98
impl Cache {
@@ -106,19 +107,19 @@ impl Cache {
106
107
/// Is the cache uninitialized?
107
108
#[ inline]
108
109
pub ( crate ) fn is_uninitialized ( & self ) -> bool {
109
- self . 0 . load ( Ordering :: Relaxed ) == usize:: max_value ( )
110
+ self . 0 . load ( Ordering :: SeqCst ) == usize:: max_value ( )
110
111
}
111
112
112
113
/// Is the `bit` in the cache set?
113
114
#[ inline]
114
115
pub ( crate ) fn test ( & self , bit : u32 ) -> bool {
115
- test_bit ( self . 0 . load ( Ordering :: Relaxed ) as u64 , bit)
116
+ test_bit ( self . 0 . load ( Ordering :: SeqCst ) as u64 , bit)
116
117
}
117
118
118
119
/// Initializes the cache.
119
120
#[ inline]
120
121
fn initialize ( & self , value : usize ) {
121
- self . 0 . store ( value, Ordering :: Relaxed ) ;
122
+ self . 0 . store ( value, Ordering :: SeqCst ) ;
122
123
}
123
124
}
124
125
0 commit comments