pub struct UserdataMarker<'a> { /* private fields */ }Expand description
Public facade over the GC mark accumulator passed to
LuaUserdata::trace.
Wraps the crate-internal Marker (private GC primitive in
runtime::heap) so embedders never see the gray-stack / weak-table
internals. Holds a mutable
borrow of the underlying marker for the duration of a single trace
call. Constructed only by the collector via the crate-internal
__new_internal constructor; embedders cannot synthesize one outside
a trace call.
§Trace-method contract
Inside LuaUserdata::trace the embedder may only:
- call
UserdataMarker::mark/UserdataMarker::mark_valueonGc<...>handles /Values reachable from&self - read fields of
&self
The embedder must not allocate new GC objects, reenter the Vm,
take locks, or perform I/O. The trace call runs synchronously inside
the collector’s mark phase and must return in bounded wall time.
Implementations§
Source§impl<'a> UserdataMarker<'a>
impl<'a> UserdataMarker<'a>
Sourcepub fn mark<T>(&mut self, g: Gc<T>) -> bool
pub fn mark<T>(&mut self, g: Gc<T>) -> bool
Mark a Gc-managed object as reachable. Returns true on the
first visit (white → gray transition). Idempotent on later
visits within the same cycle.
Sourcepub fn mark_value(&mut self, v: Value) -> bool
pub fn mark_value(&mut self, v: Value) -> bool
Convenience: mark every Gc-managed object referenced by a
Value. No-op for primitive variants (Int, Float,
Bool, Nil, LightUserdata).