File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -42,20 +42,23 @@ impl Collector {
4242
4343 // Create a new node.
4444 pub fn node ( & self ) -> Node {
45- // safety: node counts are only accessed by the current thread
46- let count = unsafe { & mut * self . node_count . load ( Thread :: current ( ) ) . get ( ) } ;
47- * count += 1 ;
48-
4945 // record the current epoch value
5046 //
5147 // note that it's fine if we see older epoch values here, which just means more
5248 // threads will be counted as active than might actually be
5349 let birth_epoch = match self . epoch_frequency {
54- // advance the global epoch
55- Some ( ref freq) if * count % freq. get ( ) == 0 => {
56- self . epoch . fetch_add ( 1 , Ordering :: Relaxed ) + 1
50+ Some ( ref epoch_frequency) => {
51+ // safety: node counts are only accessed by the current thread
52+ let count = unsafe { & mut * self . node_count . load ( Thread :: current ( ) ) . get ( ) } ;
53+ * count += 1 ;
54+
55+ // advance the global epoch
56+ if * count % epoch_frequency. get ( ) == 0 {
57+ self . epoch . fetch_add ( 1 , Ordering :: Relaxed ) + 1
58+ } else {
59+ self . epoch . load ( Ordering :: Relaxed )
60+ }
5761 }
58- Some ( _) => self . epoch . load ( Ordering :: Relaxed ) ,
5962 // we aren't tracking epochs
6063 None => 0 ,
6164 } ;
You can’t perform that action at this time.
0 commit comments