pub struct ManagedHeap<T: ManagedObject> { /* private fields */ }Expand description
A dependency-correct managed heap composed from an arena and reclamation policy.
The wrapper is generic over the guest payload and lives beside the collector, so guest runtimes do not need to duplicate policy or lifecycle behavior.
Implementations§
Source§impl<T: ManagedObject> ManagedHeap<T>
impl<T: ManagedObject> ManagedHeap<T>
Sourcepub fn tracing(cap: usize, limits: CollectionLimits) -> Result<Self, ArenaError>
pub fn tracing(cap: usize, limits: CollectionLimits) -> Result<Self, ArenaError>
Creates a heap which uses bounded tracing collection.
Sourcepub fn retaining(cap: usize) -> Result<Self, ArenaError>
pub fn retaining(cap: usize) -> Result<Self, ArenaError>
Creates a heap which retains objects until explicit teardown.
Sourcepub fn allocate(&mut self, value: T) -> Result<ManagedHandle, ArenaError>
pub fn allocate(&mut self, value: T) -> Result<ManagedHandle, ArenaError>
Allocates a value after checking the arena capacity and identity space.
Sourcepub fn get(&self, handle: ManagedHandle) -> Result<&T, ArenaError>
pub fn get(&self, handle: ManagedHandle) -> Result<&T, ArenaError>
Returns a shared value reference after validating its handle.
Sourcepub fn get_mut(&mut self, handle: ManagedHandle) -> Result<&mut T, ArenaError>
pub fn get_mut(&mut self, handle: ManagedHandle) -> Result<&mut T, ArenaError>
Returns a mutable value reference after validating its handle.
Sourcepub fn handle(&self, id: ManagedId) -> Result<ManagedHandle, ArenaError>
pub fn handle(&self, id: ManagedId) -> Result<ManagedHandle, ArenaError>
Resolves a live managed identity to its generation-checked handle.
Sourcepub fn root(
&mut self,
handle: ManagedHandle,
) -> Result<RootedHandle, ArenaError>
pub fn root( &mut self, handle: ManagedHandle, ) -> Result<RootedHandle, ArenaError>
Registers a validated handle as a tracing root.
Sourcepub fn release_root(
&mut self,
rooted: RootedHandle,
) -> Result<ManagedHandle, ArenaError>
pub fn release_root( &mut self, rooted: RootedHandle, ) -> Result<ManagedHandle, ArenaError>
Releases one matching root registration.
Sourcepub const fn policy(&self) -> ManagedHeapPolicy
pub const fn policy(&self) -> ManagedHeapPolicy
Returns the selected reclamation policy.
Sourcepub const fn cycle_leak_gap(&self) -> Option<&'static str>
pub const fn cycle_leak_gap(&self) -> Option<&'static str>
Describes the cycle-reclamation gap when retention is selected.
Sourcepub fn collect(&mut self) -> Result<Option<CollectionReceipt>, CollectionError>
pub fn collect(&mut self) -> Result<Option<CollectionReceipt>, CollectionError>
Runs the configured reclamation policy at a safepoint.
Retaining heaps return None without mutating the arena.
Sourcepub fn teardown(&mut self) -> TeardownReceipt
pub fn teardown(&mut self) -> TeardownReceipt
Removes every object and root, returning deterministic teardown evidence.