Trait shredder::marker::GcSafe [−][src]
pub unsafe trait GcSafe { }
Expand description
A marker trait that marks that data can be scanned in the background by the garbage collector.
Specifically, the requirement for implementing this trait is:
- It’s okay for any thread to call
scan
on this data, as long as it has exclusive access to the data. - It is safe for
scan
to be called on this data, even if the lifetime of this data has ended. - It is safe for
finalize
to be called on this data, even if it’s been transported to an arbitrary thread.
Importantly if a type is Send + 'static
, then it is always GcSafe
NOTE: GcSafe
cannot simply be Send + 'static
, since Gc
is always GcSafe
but sometimes is
not Send
or 'static
META NOTE: This trait exists to abstract over shredder’s “Send like” requirements. This has benefits, but it is awkward how implementing it makes promises about other traits.