Struct cell_gc::Heap
[−]
[src]
pub struct Heap { /* fields omitted */ }
Methods
impl Heap
[src]
fn new() -> Heap
Create a new, empty heap.
fn enter<R, F>(&mut self, f: F) -> R where
F: for<'h> FnOnce(&mut HeapSession<'h>) -> R,
F: for<'h> FnOnce(&mut HeapSession<'h>) -> R,
Run some code using this Heap.
Example
use cell_gc::{Heap, GCLeaf}; let mut heap = Heap::new(); heap.enter(|hs| { // ... hs.alloc(MyHeapStruct { ... }) ... });
unsafe fn pin<'h, T: IntoHeapAllocation<'h>>(&self, p: Pointer<T::In>)
Add the value *p
to the root set, protecting it from GC.
A value that has been pinned n times stays in the root set until it has been unpinned n times.
Safety
p
must point to a live allocation of type T
in this heap.
unsafe fn unpin<'h, T: IntoHeapAllocation<'h>>(&self, p: Pointer<T::In>)
Unpin a heap-allocated value (see pin
).
Safety
p
must point to a pinned allocation of type T
in this heap.
fn each_pin<F>(&self, f: F) where
F: FnMut(UntypedPointer),
F: FnMut(UntypedPointer),
Call the given function on each pinned root.
unsafe fn from_allocation<'h, T: IntoHeapAllocation<'h>>(
ptr: Pointer<T::In>
) -> *const Heap
ptr: Pointer<T::In>
) -> *const Heap
unsafe fn get_mark_bit<'h, T: IntoHeapAllocation<'h>>(
ptr: Pointer<T::In>
) -> bool
ptr: Pointer<T::In>
) -> bool