A owned handle which points to a garbage collected object.
This is considered a root by the garbage collector that is independent of any specific GcContext. Safepoints don't need to be informed of this object for collection to start. The root is manually managed by user-code, much like a Box or a reference counted pointer.
This can be cloned and stored independently from a context, bridging the gap between native memory and managed memory. These are useful to pass to C APIs or any other code that doesn't cooperate with zerogc.
The object behind this handle is already considered a root of the collection. It should always be considered reachable by the garbage collector.
Validity is tracked by this smart-pointer and not by tracing. Therefore it is safe to implement NullTrace for handles.
The type of the system used with this handle
type Id: CollectorId[src]
The type of CollectorId used with this sytem
pub fn use_critical<R>(&self, func: impl FnOnce(&T) -> R) -> R[src]
Access this handle inside the closure, possibly associating it with the specified
This is accesses the object within "critical section" that will block collections for as long as the closure is in use.
These calls cannot be invoked recursively or they may cause a deadlock.
This is similar in purpose to JNI's GetPrimitiveArrayCritical. However it never performs a copy, it is just guarenteed to block any collections.