Skip to main content

ManagedArena

Struct ManagedArena 

Source
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>

Source

pub fn new(policy: HardCappedRetainPolicy) -> Self

Creates an empty arena using the hard-capped retain policy.

Source

pub const fn trace_contract_version(&self) -> TraceContractVersion

Returns the tracing contract version.

Source

pub fn len(&self) -> usize

Returns the number of live objects.

Source

pub fn is_empty(&self) -> bool

Reports whether the arena contains no objects.

Source

pub const fn mutation_epoch(&self) -> u64

Returns the epoch advanced by every graph-affecting arena mutation.

Source

pub fn allocate(&mut self, object: T) -> Result<ManagedHandle, ArenaError>

Allocates atomically after checking the cap and identity space.

Source

pub fn get(&self, handle: ManagedHandle) -> Result<&T, ArenaError>

Returns a shared object reference, refusing stale handles.

Source

pub fn get_mut(&mut self, handle: ManagedHandle) -> Result<&mut T, ArenaError>

Returns a mutable object reference, refusing stale handles.

Source

pub fn upgrade(&mut self, weak: WeakHandle) -> Result<ManagedHandle, ArenaError>

Upgrades a weak handle only while its object remains live.

Source

pub fn handle(&self, id: ManagedId) -> Result<ManagedHandle, ArenaError>

Resolves a tracing identity to a live handle for collector operations.

Source

pub fn root( &mut self, handle: ManagedHandle, ) -> Result<RootedHandle, ArenaError>

Registers a root after validating the handle.

Source

pub fn release_root( &mut self, rooted: RootedHandle, ) -> Result<ManagedHandle, ArenaError>

Releases exactly one matching root registration.

Source

pub fn remove(&mut self, handle: ManagedHandle) -> Result<T, ArenaError>

Removes an unrooted object, making all handles to it stale.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn teardown(&mut self) -> TeardownReceipt

Tears down all storage and roots, returning allocation-ordered evidence.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.