[][src]Crate gc_arena

Macros

make_arena

Creates a new "garbage collected arena" type. The macro takes two parameters, the name you would like to give the arena type, and the type of the arena root. The root type must implement the Collect trait, and be a type that takes a single generic lifetime parameter which is used for any held Gc pointer types.

static_collect

If a type is static, we know that it can never hold Gc pointers, so it is safe to provide a simple empty Collect implementation. Collect implementation.

unsafe_empty_collect

If a type will never hold Gc pointers, you can use this macro to provide a simple empty Collect implementation.

Structs

ArenaParameters
CollectionContext

Handle value given by arena callbacks during garbage collection, which must be passed through Collect::trace implementations.

Gc

A garbage collected pointer to a type T. Implements Copy, and is implemented as a plain machine pointer. You can only allocate Gc pointers through an Allocator inside an arena type, and through "generativity" such Gc pointers may not escape the arena they were born in or be stored inside TLS. This, combined with correct Collect implementations, means that Gc pointers will never be dangling and are always safe to access.

GcCell

A garbage collected pointer to a type T that may be safely mutated. When a type that may hold Gc pointers is mutated, it may adopt new Gc pointers, and in order for this to be safe this must be accompanied by a call to Gc::write_barrier. This type wraps the given T in a RefCell in such a way that writing to the RefCell is always accompanied by a call to Gc::write_barrier.

MutationContext

Handle value given by arena callbacks during construction and mutation. Allows allocating new Gc pointers and internally mutating values held by Gc pointers.

StaticCollect

A wrapper type that implements Collect whenever the contained T is 'static, which is useful in generic contexts

Traits

Collect

A trait for garbage collected objects that can be placed into Gc pointers. This trait is unsafe, because Gc pointers inside an Arena are assumed never to be dangling, and in order to ensure this certain rules must be followed:

Functions

rootless_arena

Create a temporary arena without a root object and perform the given operation on it. No garbage collection will be done until the very end of the call, at which point all allocations will be collected.