ObjectTracerContext

Trait ObjectTracerContext 

Source
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§

Source

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§

Source

fn with_tracer<'w, R, F>(&self, worker: &'w mut GCWorker<VM>, func: F) -> R
where 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

  1. on which fields the user is supposed to call ObjectTracer::trace_object, and
  2. 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 created ObjectTracer can 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.

Implementors§