1
1
use core:: ptr:: { self , NonNull } ;
2
2
#[ cfg( not( feature = "check-loom" ) ) ]
3
- use core:: sync:: atomic:: { fence , AtomicBool , AtomicPtr , AtomicUsize , Ordering } ;
3
+ use core:: sync:: atomic:: { AtomicBool , AtomicPtr , AtomicUsize , Ordering , fence } ;
4
4
use std:: collections:: HashSet ;
5
5
use std:: fmt;
6
6
7
7
#[ cfg( feature = "check-loom" ) ]
8
- use loom:: sync:: atomic:: { fence , AtomicBool , AtomicPtr , AtomicUsize , Ordering } ;
8
+ use loom:: sync:: atomic:: { AtomicBool , AtomicPtr , AtomicUsize , Ordering , fence } ;
9
9
10
10
use super :: HAZARDS ;
11
11
@@ -98,7 +98,7 @@ struct HazardSlot {
98
98
// Whether this slot is occupied by a `Shield`.
99
99
active : AtomicBool ,
100
100
// Machine representation of the hazard pointer.
101
- hazard : AtomicUsize ,
101
+ hazard : AtomicPtr < ( ) > ,
102
102
// Immutable pointer to the next slot in the bag.
103
103
next : * const HazardSlot ,
104
104
}
@@ -138,7 +138,7 @@ impl HazardBag {
138
138
}
139
139
140
140
/// Returns all the hazards in the set.
141
- pub fn all_hazards ( & self ) -> HashSet < usize > {
141
+ pub fn all_hazards ( & self ) -> HashSet < * mut ( ) > {
142
142
todo ! ( )
143
143
}
144
144
}
@@ -163,8 +163,8 @@ unsafe impl Sync for HazardSlot {}
163
163
mod tests {
164
164
use std:: collections:: HashSet ;
165
165
use std:: ops:: Range ;
166
- use std:: sync:: atomic:: AtomicPtr ;
167
166
use std:: sync:: Arc ;
167
+ use std:: sync:: atomic:: AtomicPtr ;
168
168
use std:: { mem, thread} ;
169
169
170
170
use super :: { HazardBag , Shield } ;
@@ -193,7 +193,7 @@ mod tests {
193
193
. into_iter ( )
194
194
. for_each ( |th| th. join ( ) . unwrap ( ) ) ;
195
195
let all = hazard_bag. all_hazards ( ) ;
196
- let values = VALUES . collect ( ) ;
196
+ let values = VALUES . map ( |data| data as * mut ( ) ) . collect ( ) ;
197
197
assert ! ( all. is_superset( & values) )
198
198
}
199
199
@@ -216,7 +216,7 @@ mod tests {
216
216
. into_iter ( )
217
217
. for_each ( |th| th. join ( ) . unwrap ( ) ) ;
218
218
let all = hazard_bag. all_hazards ( ) ;
219
- let values = VALUES . collect ( ) ;
219
+ let values = VALUES . map ( |data| data as * mut ( ) ) . collect ( ) ;
220
220
let intersection: HashSet < _ > = all. intersection ( & values) . collect ( ) ;
221
221
assert ! ( intersection. is_empty( ) )
222
222
}
0 commit comments