pub struct GcHeap { /* private fields */ }Expand description
Backward-compatible GC heap interface backed by ObjectSlab.
All mark-sweep semantics have been removed. Objects are reference-counted and freed deterministically when no references remain.
Implementations§
Source§impl GcHeap
impl GcHeap
Sourcepub fn new(_collection_threshold: usize) -> Self
pub fn new(_collection_threshold: usize) -> Self
Create a new heap. The _collection_threshold parameter is accepted
for API compatibility but ignored (no automatic collection in RC mode).
Sourcepub fn alloc<T: Any + 'static>(&mut self, value: T) -> GcRef
pub fn alloc<T: Any + 'static>(&mut self, value: T) -> GcRef
Allocate a value on the heap, returning a handle.
Sourcepub fn alloc_auto<T: Any + 'static>(
&mut self,
value: T,
_roots: &[GcRef],
) -> GcRef
pub fn alloc_auto<T: Any + 'static>( &mut self, value: T, _roots: &[GcRef], ) -> GcRef
Allocate with “auto-collection” — for API compat.
The _roots parameter is ignored (no GC to trigger).
Sourcepub fn get<T: Any + 'static>(&self, gc_ref: GcRef) -> Option<&T>
pub fn get<T: Any + 'static>(&self, gc_ref: GcRef) -> Option<&T>
Read a reference to the value behind gc_ref, downcasting to T.
Sourcepub fn collect(&mut self, _roots: &[GcRef])
pub fn collect(&mut self, _roots: &[GcRef])
No-op: mark-sweep has been removed. Objects are reference-counted.
Sourcepub fn live_count(&self) -> usize
pub fn live_count(&self) -> usize
Number of live objects on the heap.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GcHeap
impl !RefUnwindSafe for GcHeap
impl !Send for GcHeap
impl !Sync for GcHeap
impl Unpin for GcHeap
impl UnsafeUnpin for GcHeap
impl !UnwindSafe for GcHeap
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more