pub struct ManagedArena<T> { /* private fields */ }Expand description
Bounded storage for managed objects, independent of language and collector policy.
Implementations§
Source§impl<T> ManagedArena<T>
impl<T> ManagedArena<T>
Sourcepub fn new(policy: HardCappedRetainPolicy) -> Self
pub fn new(policy: HardCappedRetainPolicy) -> Self
Creates an empty arena using the hard-capped retain policy.
Sourcepub const fn trace_contract_version(&self) -> TraceContractVersion
pub const fn trace_contract_version(&self) -> TraceContractVersion
Returns the tracing contract version.
Sourcepub const fn mutation_epoch(&self) -> u64
pub const fn mutation_epoch(&self) -> u64
Returns the epoch advanced by every graph-affecting arena mutation.
Sourcepub fn allocate(&mut self, object: T) -> Result<ManagedHandle, ArenaError>
pub fn allocate(&mut self, object: T) -> Result<ManagedHandle, ArenaError>
Allocates atomically after checking the cap and identity space.
Sourcepub fn get(&self, handle: ManagedHandle) -> Result<&T, ArenaError>
pub fn get(&self, handle: ManagedHandle) -> Result<&T, ArenaError>
Returns a shared object reference, refusing stale handles.
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 object reference, refusing stale handles.
Sourcepub fn upgrade(&mut self, weak: WeakHandle) -> Result<ManagedHandle, ArenaError>
pub fn upgrade(&mut self, weak: WeakHandle) -> Result<ManagedHandle, ArenaError>
Upgrades a weak handle only while its object remains live.
Sourcepub fn handle(&self, id: ManagedId) -> Result<ManagedHandle, ArenaError>
pub fn handle(&self, id: ManagedId) -> Result<ManagedHandle, ArenaError>
Resolves a tracing identity to a live handle for collector operations.
Sourcepub fn root(
&mut self,
handle: ManagedHandle,
) -> Result<RootedHandle, ArenaError>
pub fn root( &mut self, handle: ManagedHandle, ) -> Result<RootedHandle, ArenaError>
Registers a root after validating the handle.
Sourcepub fn release_root(
&mut self,
rooted: RootedHandle,
) -> Result<ManagedHandle, ArenaError>
pub fn release_root( &mut self, rooted: RootedHandle, ) -> Result<ManagedHandle, ArenaError>
Releases exactly one matching root registration.
Sourcepub fn remove(&mut self, handle: ManagedHandle) -> Result<T, ArenaError>
pub fn remove(&mut self, handle: ManagedHandle) -> Result<T, ArenaError>
Removes an unrooted object, making all handles to it stale.
Sourcepub fn clear_weak_edge(
&mut self,
owner: ManagedHandle,
edge: EdgeId,
expected: WeakHandle,
) -> Result<bool, ArenaError>where
T: ManagedObject,
pub fn clear_weak_edge(
&mut self,
owner: ManagedHandle,
edge: EdgeId,
expected: WeakHandle,
) -> Result<bool, ArenaError>where
T: ManagedObject,
Clears a weak edge through the owning object’s at-most-once operation.
Sourcepub fn sweep_at_epoch(
&mut self,
expected_epoch: u64,
objects: &[ManagedId],
) -> Result<Vec<ManagedId>, ArenaError>
pub fn sweep_at_epoch( &mut self, expected_epoch: u64, objects: &[ManagedId], ) -> Result<Vec<ManagedId>, ArenaError>
Atomically removes an allocation-ordered set selected from expected_epoch.
Every identity and root condition is checked before the first slot changes.
Sourcepub fn apply_collection_at_epoch(
&mut self,
expected_epoch: u64,
weak: &[(ManagedId, EdgeId, ManagedId)],
ephemerons: &[(ManagedId, EdgeId, ManagedId, ManagedId)],
swept: &[ManagedId],
) -> Result<CollectionMutationReceipt, ArenaError>where
T: ManagedObject,
pub fn apply_collection_at_epoch(
&mut self,
expected_epoch: u64,
weak: &[(ManagedId, EdgeId, ManagedId)],
ephemerons: &[(ManagedId, EdgeId, ManagedId, ManagedId)],
swept: &[ManagedId],
) -> Result<CollectionMutationReceipt, ArenaError>where
T: ManagedObject,
Applies a collector plan atomically at expected_epoch.
Kept-alive objects from that epoch are retained. Weak and ephemeron entries are cleared before unreachable objects are removed, and every conditional clear is intrinsically at most once.
Sourcepub fn safepoint<R>(
&mut self,
trace: impl FnOnce(&TraceSnapshot<'_, T>) -> R,
) -> Result<(R, SafepointReceipt), ArenaError>where
T: ManagedObject,
pub fn safepoint<R>(
&mut self,
trace: impl FnOnce(&TraceSnapshot<'_, T>) -> R,
) -> Result<(R, SafepointReceipt), ArenaError>where
T: ManagedObject,
Runs a read-only tracing callback at a deterministic safepoint.
Sourcepub fn teardown(&mut self) -> TeardownReceipt
pub fn teardown(&mut self) -> TeardownReceipt
Tears down all storage and roots, returning allocation-ordered evidence.