Struct rcgc::Gc

source ·
pub struct Gc<T: Trace> { /* private fields */ }
Expand description

A garbage collector managing objects of type T.

When dropped, all unrooted objects will be destroyed. Any rooted objects should no longer be used.

Implementations§

Allocate t on the garbage-collected heap without triggering a collection.

Collect each and every garbage object, atomically.

The root set is determined by taking all objects whose strong reference count >1. This only happens during active access (which implies that the object is still reachable) and because there’s a Rooted instance pointing to the object.

As an optimization, whenever we come across an object with a weak count of 0, we know that it has no traced reference pointing to it. If that object also has a strong count of 1, that object isn’t rooted (the only strong reference coming from the GC itself) and can be freed immediately without having to finish the mark phase. Note that this might in turn drop the weak count to other objects to 0 and make them collectible.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.