@@ -2,9 +2,9 @@ use crate::tls::Thread;
22use crate :: { raw, LocalGuard , OwnedGuard } ;
33
44use std:: cell:: UnsafeCell ;
5+ use std:: fmt;
56use std:: num:: NonZeroU64 ;
6- use std:: sync:: atomic:: Ordering ;
7- use std:: { fmt, ptr} ;
7+ use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
88
99/// Fast, efficient, and robust memory reclamation.
1010///
@@ -13,8 +13,8 @@ use std::{fmt, ptr};
1313/// the [`enter`](Collector::enter) or [`enter_owned`](Collector::enter_owned)
1414/// methods.
1515pub struct Collector {
16+ id : usize ,
1617 pub ( crate ) raw : raw:: Collector ,
17- unique : * mut u8 ,
1818}
1919
2020unsafe impl Send for Collector { }
@@ -26,13 +26,15 @@ impl Collector {
2626
2727 /// Creates a new collector.
2828 pub fn new ( ) -> Self {
29+ static ID : AtomicUsize = AtomicUsize :: new ( 0 ) ;
30+
2931 let cpus = std:: thread:: available_parallelism ( )
3032 . map ( Into :: into)
3133 . unwrap_or ( 1 ) ;
3234
3335 Self {
3436 raw : raw:: Collector :: new ( cpus, Self :: DEFAULT_EPOCH_TICK , Self :: DEFAULT_RETIRE_TICK ) ,
35- unique : Box :: into_raw ( Box :: new ( 0 ) ) ,
37+ id : ID . fetch_add ( 1 , Ordering :: Relaxed ) ,
3638 }
3739 }
3840
@@ -284,14 +286,8 @@ impl Collector {
284286 unsafe { self . raw . reclaim_all ( ) } ;
285287 }
286288
287- pub ( crate ) fn ptr_eq ( this : & Collector , other : & Collector ) -> bool {
288- ptr:: eq ( this. unique , other. unique )
289- }
290- }
291-
292- impl Drop for Collector {
293- fn drop ( & mut self ) {
294- let _ = unsafe { Box :: from_raw ( self . unique ) } ;
289+ pub ( crate ) fn id_eq ( this : & Collector , other : & Collector ) -> bool {
290+ this. id == other. id
295291 }
296292}
297293
0 commit comments