@@ -89,9 +89,10 @@ static CACHE: [Cache; 2] = [Cache::uninitialized(), Cache::uninitialized()];
8989/// Note: the last feature bit is used to represent an
9090/// uninitialized cache.
9191///
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
9393/// 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.
9596struct Cache ( AtomicUsize ) ;
9697
9798impl Cache {
@@ -106,19 +107,19 @@ impl Cache {
106107 /// Is the cache uninitialized?
107108 #[ inline]
108109 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 ( )
110111 }
111112
112113 /// Is the `bit` in the cache set?
113114 #[ inline]
114115 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)
116117 }
117118
118119 /// Initializes the cache.
119120 #[ inline]
120121 fn initialize ( & self , value : usize ) {
121- self . 0 . store ( value, Ordering :: Relaxed ) ;
122+ self . 0 . store ( value, Ordering :: SeqCst ) ;
122123 }
123124}
124125
0 commit comments