GcRuntime

Trait GcRuntime 

Source
pub trait GcRuntime: Send + Sync {
    type Array: Array;

    // Required methods
    fn alloc(&self, ty: &Type) -> GcPtr;
    fn alloc_array(&self, ty: &Type, n: usize) -> Self::Array;
    fn ptr_type(&self, obj: GcPtr) -> Type;
    fn array(&self, handle: GcPtr) -> Option<Self::Array>;
    fn root(&self, obj: GcPtr);
    fn unroot(&self, obj: GcPtr);
    fn stats(&self) -> Stats;
}
Expand description

An object that can be used to allocate and collect memory.

Required Associated Types§

Required Methods§

Source

fn alloc(&self, ty: &Type) -> GcPtr

Allocates an object of the given type returning a GcPtr

Source

fn alloc_array(&self, ty: &Type, n: usize) -> Self::Array

Allocates an array of the given type. ty must be an array type.

Source

fn ptr_type(&self, obj: GcPtr) -> Type

Returns the type of the specified obj.

Source

fn array(&self, handle: GcPtr) -> Option<Self::Array>

Returns array information of the specified handle

Source

fn root(&self, obj: GcPtr)

Roots the specified obj, which keeps it and objects it references alive. Objects marked as root, must call unroot before they can be collected. An object can be rooted multiple times, but you must make sure to call unroot an equal number of times before the object can be collected.

Source

fn unroot(&self, obj: GcPtr)

Unroots the specified obj, potentially allowing it and objects it references to be collected. An object can be rooted multiple times, so you must make sure to call unroot the same number of times as root was called before the object can be collected.

Source

fn stats(&self) -> Stats

Returns stats about the current state of the runtime.

Implementors§

Source§

impl<O> GcRuntime for MarkSweep<O>
where O: Observer<Event = Event>,

Source§

type Array = ArrayHandle