[][src]Trait scoped_gc::Trace

pub unsafe trait Trace {
    unsafe fn mark(&self);
unsafe fn root(&self);
unsafe fn unroot(&self); }

Used to propagate signals across the objects graph of values managed by the garbage collector.

This trait is unsafe because an invalid implementations may cause dangling pointers. For example, if trace is not propagated to a reachable Gc pointers then its value may be freed. The next dereference of this Gc causes then an error.

You should never initiate the traversal of the object graph: it is the role of the library. Propagating a signal at the wrong time may cause an invalid state leading to dangling pointers.

Required methods

unsafe fn mark(&self)

Propagates the mark signal across the objects graph.

This signal is used during the first phase of garbage collection to mark the values that are still reachable.

The signal is initiated at the rooted values and propagated to reach the adjacent Gc pointers. If their value is not already marked they mark it and propagate the signal further in the graph.

unsafe fn root(&self)

Propagates the root signal across the objects graph.

This signal is used to signal that there is a new root pointing to a managed value. This prevents this value (and any other value reachable from it) from being collected.

This is initiated when creating a new Gc pointer or mutably borrowing the value inside a GcRefCell.

unsafe fn unroot(&self)

Propagates the unroot signal across the objects graph.

This signal is used to signal the destruction of a root pointing to a managed value. If this was the last root, the value is not longer used to initiate mark signals: if there are no other rooted values that can reach it, it becomes eligible for garbage collection.

This is initiated when a Gc pointer or mutably borrowing the value inside a GcRefCell.

Loading content...

Implementations on Foreign Types

impl Trace for ()[src]

impl Trace for bool[src]

impl Trace for u8[src]

impl Trace for u16[src]

impl Trace for u32[src]

impl Trace for u64[src]

impl Trace for usize[src]

impl Trace for i8[src]

impl Trace for i16[src]

impl Trace for i32[src]

impl Trace for i64[src]

impl Trace for isize[src]

impl Trace for f32[src]

impl Trace for f64[src]

impl Trace for char[src]

impl Trace for String[src]

impl Trace for Path[src]

impl Trace for PathBuf[src]

impl Trace for AtomicBool[src]

impl Trace for AtomicIsize[src]

impl Trace for AtomicUsize[src]

impl<T: Trace> Trace for Range<T>[src]

impl<T: Trace> Trace for Box<T>[src]

impl<T: Trace> Trace for Option<T>[src]

impl<T: Trace, E: Trace> Trace for Result<T, E>[src]

impl<T: Trace> Trace for Vec<T>[src]

impl<K: Eq + Hash + Trace, V: Trace> Trace for HashMap<K, V>[src]

impl<K: Eq + Ord + Trace, V: Trace> Trace for BTreeMap<K, V>[src]

impl<'a> Trace for &'a str[src]

Loading content...

Implementors

impl<'gc, T: Trace> Trace for Gc<'gc, T>[src]

unsafe fn mark(&self)[src]

Marks the value in the GcBox as reachable.

The mark signal will be propagated further in the object graph unless the box was already marked (to avoid infinite loops on cycles, or redundant traversals).

unsafe fn root(&self)[src]

Tags this Gc pointer as a root for its value.

unsafe fn unroot(&self)[src]

Untags this Gc pointer as a root for its value.

impl<T: Trace> Trace for GcRefCell<T>[src]

Loading content...