pub struct Heap { /* private fields */ }Implementations§
Source§impl Heap
impl Heap
Sourcepub fn enter<R, F>(&mut self, f: F) -> Rwhere
F: for<'h> FnOnce(&mut HeapSession<'h>) -> R,
pub fn enter<R, F>(&mut self, f: F) -> Rwhere
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 { ... }) ...
});Sourcepub unsafe fn pin<'h, T: IntoHeapAllocation<'h>>(&self, p: Pointer<T::In>)
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.
Sourcepub unsafe fn unpin<'h, T: IntoHeapAllocation<'h>>(&self, p: Pointer<T::In>)
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.
Sourcepub fn each_pin<F>(&self, f: F)where
F: FnMut(UntypedPointer),
pub fn each_pin<F>(&self, f: F)where
F: FnMut(UntypedPointer),
Call the given function on each pinned root.
pub unsafe fn from_allocation<'h, T: IntoHeapAllocation<'h>>( ptr: Pointer<T::In>, ) -> *const Heap
pub unsafe fn get_mark_bit<'h, T: IntoHeapAllocation<'h>>( ptr: Pointer<T::In>, ) -> bool
pub unsafe fn set_mark_bit<'h, T: IntoHeapAllocation<'h>>(ptr: Pointer<T::In>)
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more