pub struct ManagedArena<T> { /* private fields */ }Expand description
Shared language-neutral arena, node, edge, and retention building blocks. 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) -> ManagedArena<T>
pub fn new(policy: HardCappedRetainPolicy) -> ManagedArena<T>
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.
Source§impl<T> ManagedArena<T>where
T: RoleBearingManagedObject,
impl<T> ManagedArena<T>where
T: RoleBearingManagedObject,
Sourcepub fn replace_role(
&mut self,
handle: ManagedHandle,
role: <T as RoleBearingManagedObject>::Role,
) -> Result<<T as RoleBearingManagedObject>::Role, ArenaError>
pub fn replace_role( &mut self, handle: ManagedHandle, role: <T as RoleBearingManagedObject>::Role, ) -> Result<<T as RoleBearingManagedObject>::Role, ArenaError>
Replaces caller-owned role evidence without advancing the graph epoch.
Sourcepub fn project_roles(
&mut self,
limit: usize,
) -> Result<RoleProjectionReceipt<<T as RoleBearingManagedObject>::Role>, RoleProjectionError>
pub fn project_roles( &mut self, limit: usize, ) -> Result<RoleProjectionReceipt<<T as RoleBearingManagedObject>::Role>, RoleProjectionError>
Projects optional owner-role evidence at a read-only safepoint.
Admission is checked before invoking role, and rows follow managed id
order. The projection observes objects but is not visible to tracing or
collector policy.
Auto Trait Implementations§
impl<T> Freeze for ManagedArena<T>
impl<T> RefUnwindSafe for ManagedArena<T>where
T: RefUnwindSafe,
impl<T> Send for ManagedArena<T>where
T: Send,
impl<T> Sync for ManagedArena<T>where
T: Sync,
impl<T> Unpin for ManagedArena<T>
impl<T> UnsafeUnpin for ManagedArena<T>
impl<T> UnwindSafe for ManagedArena<T>where
T: RefUnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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