pub trait ObjectTracerContext<VM: VMBinding>:
Clone
+ Send
+ 'static {
type TracerType<'w>: ObjectTracer;
// Required method
fn with_tracer<'w, R, F>(&self, worker: &'w mut GCWorker<VM>, func: F) -> R
where F: FnOnce(&mut Self::TracerType<'w>) -> R;
}Expand description
An ObjectTracerContext gives a GC worker temporary access to an ObjectTracer, allowing the
GC worker to trace objects. This trait is intended to abstract out the implementation details
of tracing objects, enqueuing objects, and creating work packets that expand the transitive
closure, allowing the VM binding to focus on VM-specific parts.
This trait is used during root scanning and binding-side weak reference processing.
Required Associated Types§
Sourcetype TracerType<'w>: ObjectTracer
type TracerType<'w>: ObjectTracer
The concrete ObjectTracer type.
The lifetime parameter 'w is the lifetime of the &'w mut GCWorker<VM> passed to the
Self::with_tracer method. It is borrowed by the ObjectTracer passed to the func
callback of Self::with_tracer.
Required Methods§
Sourcefn with_tracer<'w, R, F>(&self, worker: &'w mut GCWorker<VM>, func: F) -> Rwhere
F: FnOnce(&mut Self::TracerType<'w>) -> R,
fn with_tracer<'w, R, F>(&self, worker: &'w mut GCWorker<VM>, func: F) -> Rwhere
F: FnOnce(&mut Self::TracerType<'w>) -> R,
Create a temporary ObjectTracer and provide access in the scope of func.
When ObjectTracer::trace_object is called, if the traced object is first visited in this
transitive closure, it will be enqueued. After func returns, the implememtation will
create work packets to continue computing the transitive closure from the newly enqueued
objects.
API functions that provide ObjectTracerContext should document
- on which fields the user is supposed to call
ObjectTracer::trace_object, and - which work bucket the generated work packet will be added to. Sometimes the user needs to know when the computing of transitive closure finishes.
Arguments:
worker: The current GC worker.func: A caller-supplied closure in which the createdObjectTracercan be used.
Returns: The return value of func.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.