11use std:: sync:: atomic:: { AtomicBool , AtomicUsize , Ordering } ;
22use std:: sync:: Mutex ;
3+ use std:: time:: Instant ;
4+
5+ use atomic_refcell:: AtomicRefCell ;
36
47/// This stores some global states for an MMTK instance.
58/// Some MMTK components like plans and allocators may keep an reference to the struct, and can access it.
@@ -15,6 +18,8 @@ pub struct GlobalState {
1518 pub ( crate ) initialized : AtomicBool ,
1619 /// The current GC status.
1720 pub ( crate ) gc_status : Mutex < GcStatus > ,
21+ /// When did the last GC start? Only accessed by the last parked worker.
22+ pub ( crate ) gc_start_time : AtomicRefCell < Option < Instant > > ,
1823 /// Is the current GC an emergency collection? Emergency means we may run out of memory soon, and we should
1924 /// attempt to collect as much as we can.
2025 pub ( crate ) emergency_collection : AtomicBool ,
@@ -195,6 +200,7 @@ impl Default for GlobalState {
195200 Self {
196201 initialized : AtomicBool :: new ( false ) ,
197202 gc_status : Mutex :: new ( GcStatus :: NotInGC ) ,
203+ gc_start_time : AtomicRefCell :: new ( None ) ,
198204 stacks_prepared : AtomicBool :: new ( false ) ,
199205 emergency_collection : AtomicBool :: new ( false ) ,
200206 user_triggered_collection : AtomicBool :: new ( false ) ,
0 commit comments