Heap

Struct Heap 

Source
pub struct Heap { /* private fields */ }

Implementations§

Source§

impl Heap

Source

pub fn new() -> Heap

Create a new, empty heap.

Source

pub fn enter<R, F>(&mut self, f: F) -> R
where 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 { ... }) ...
});
Source

pub 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.

Source

pub 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.

Source

pub fn each_pin<F>(&self, f: F)

Call the given function on each pinned root.

Source

pub unsafe fn from_allocation<'h, T: IntoHeapAllocation<'h>>( ptr: Pointer<T::In>, ) -> *const Heap

Source

pub unsafe fn get_mark_bit<'h, T: IntoHeapAllocation<'h>>( ptr: Pointer<T::In>, ) -> bool

Source

pub unsafe fn set_mark_bit<'h, T: IntoHeapAllocation<'h>>(ptr: Pointer<T::In>)

Trait Implementations§

Source§

impl Drop for Heap

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl !Freeze for Heap

§

impl !RefUnwindSafe for Heap

§

impl !Send for Heap

§

impl !Sync for Heap

§

impl Unpin for Heap

§

impl !UnwindSafe for Heap

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.