pub struct Gc<T: ?Sized> { /* private fields */ }Expand description
A GC-managed pointer. Copy + Clone (one-machine-word). Replaces GcRef<T>.
Implementations§
Source§impl<T: Trace + 'static> Gc<T>
impl<T: Trace + 'static> Gc<T>
Sourcepub fn new_uncollected(value: T) -> Self
pub fn new_uncollected(value: T) -> Self
Allocate a GcBox<T> outside any heap registry. Used by legacy
GcRef::new call sites until Phase D-1b migrates them. The returned
Gc<T> is reachable only through the caller’s own retention path;
without joining a heap’s allgc chain, it will never be swept (so
effectively leaks until process exit — same as Rc behavior).
Source§impl<T: ?Sized> Gc<T>
impl<T: ?Sized> Gc<T>
Sourcepub fn ptr_eq(a: Self, b: Self) -> bool
pub fn ptr_eq(a: Self, b: Self) -> bool
Two Gc<T>s are identity-equal iff they point at the same box.
Sourcepub fn identity(self) -> usize
pub fn identity(self) -> usize
Identity as a usize — usable as a hash table key for “is the same object” lookups.
Sourcepub fn account_buffer(&self, heap: &Heap, delta: isize)
pub fn account_buffer(&self, heap: &Heap, delta: isize)
Charge (delta > 0) or refund (delta < 0) delta bytes of this
object’s owned heap buffers against the pacer, keeping header.size
as the single source of truth for what sweep will refund.
No-op when delta == 0 or when this box is not on a heap allgc chain
(collected == false): an uncollected box is never swept, so charging
it would permanently inflate the byte counter. On the collected path,
header.size and the heap’s byte counter move together, so after sweep
frees this box it refunds exactly the bytes that were charged here.
Trait Implementations§
Source§impl<T: Trace + 'static> Trace for Gc<T>
Gc<T> is itself traceable: marking it forwards to the contained T.
impl<T: Trace + 'static> Trace for Gc<T>
Gc<T> is itself traceable: marking it forwards to the contained T.