11use core:: ptr:: { self , NonNull } ;
22#[ 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 } ;
44use std:: collections:: HashSet ;
55use std:: fmt;
66
77#[ cfg( feature = "check-loom" ) ]
8- use loom:: sync:: atomic:: { fence , AtomicBool , AtomicPtr , AtomicUsize , Ordering } ;
8+ use loom:: sync:: atomic:: { AtomicBool , AtomicPtr , AtomicUsize , Ordering , fence } ;
99
1010use super :: HAZARDS ;
1111
@@ -98,7 +98,7 @@ struct HazardSlot {
9898 // Whether this slot is occupied by a `Shield`.
9999 active : AtomicBool ,
100100 // Machine representation of the hazard pointer.
101- hazard : AtomicUsize ,
101+ hazard : AtomicPtr < ( ) > ,
102102 // Immutable pointer to the next slot in the bag.
103103 next : * const HazardSlot ,
104104}
@@ -138,7 +138,7 @@ impl HazardBag {
138138 }
139139
140140 /// Returns all the hazards in the set.
141- pub fn all_hazards ( & self ) -> HashSet < usize > {
141+ pub fn all_hazards ( & self ) -> HashSet < * mut ( ) > {
142142 todo ! ( )
143143 }
144144}
@@ -163,8 +163,8 @@ unsafe impl Sync for HazardSlot {}
163163mod tests {
164164 use std:: collections:: HashSet ;
165165 use std:: ops:: Range ;
166- use std:: sync:: atomic:: AtomicPtr ;
167166 use std:: sync:: Arc ;
167+ use std:: sync:: atomic:: AtomicPtr ;
168168 use std:: { mem, thread} ;
169169
170170 use super :: { HazardBag , Shield } ;
@@ -193,7 +193,7 @@ mod tests {
193193 . into_iter ( )
194194 . for_each ( |th| th. join ( ) . unwrap ( ) ) ;
195195 let all = hazard_bag. all_hazards ( ) ;
196- let values = VALUES . collect ( ) ;
196+ let values = VALUES . map ( |data| data as * mut ( ) ) . collect ( ) ;
197197 assert ! ( all. is_superset( & values) )
198198 }
199199
@@ -216,7 +216,7 @@ mod tests {
216216 . into_iter ( )
217217 . for_each ( |th| th. join ( ) . unwrap ( ) ) ;
218218 let all = hazard_bag. all_hazards ( ) ;
219- let values = VALUES . collect ( ) ;
219+ let values = VALUES . map ( |data| data as * mut ( ) ) . collect ( ) ;
220220 let intersection: HashSet < _ > = all. intersection ( & values) . collect ( ) ;
221221 assert ! ( intersection. is_empty( ) )
222222 }
0 commit comments