Skip to main content

CacheBlockLifecycle

Struct CacheBlockLifecycle 

Source
pub struct CacheBlockLifecycle { /* private fields */ }
Expand description

Canonical logical ownership state for one backend cache session.

Backends keep concrete arrays, buffers, files, and completion objects in a separate storage map keyed by CacheBlockId. This catalog is the sole owner of leases, access order, protected-prefix status, and mutable tails.

Implementations§

Source§

impl CacheBlockLifecycle

Source

pub const fn new() -> Self

Creates an empty cache-session lifecycle.

Source

pub fn insert( &mut self, id: CacheBlockId, protected_prefix: bool, ) -> Result<(), CacheLifecycleError>

Registers a newly materialized immutable block.

Source

pub fn remove(&mut self, id: &CacheBlockId) -> Result<(), CacheLifecycleError>

Removes an unleased block from logical ownership.

Source

pub fn replace( &mut self, removals: &[(CacheBlockId, usize)], replacement: Option<(CacheBlockId, bool)>, tail_layer: usize, tail: MutableCacheTail, ) -> Result<(), CacheLifecycleError>

Atomically replaces a set of blocks and updates one mutable tail.

The expected lease count makes a caller-owned truncation lease explicit: validation completes before any logical state is changed.

Source

pub fn acquire(&mut self, id: &CacheBlockId) -> Result<(), CacheLifecycleError>

Acquires one exact logical lease and records demand access.

Source

pub fn release(&mut self, id: &CacheBlockId) -> Result<(), CacheLifecycleError>

Releases one exact logical lease.

Source

pub fn lease_count( &self, id: &CacheBlockId, ) -> Result<usize, CacheLifecycleError>

Returns the exact lease count for a block.

Source

pub fn is_leased(&self, id: &CacheBlockId) -> Result<bool, CacheLifecycleError>

Returns whether a block currently has any logical owner.

Source

pub fn first_leased(&self) -> Option<&CacheBlockId>

Returns the first leased block in stable identity order.

Source

pub fn is_protected_prefix( &self, id: &CacheBlockId, ) -> Result<bool, CacheLifecycleError>

Returns whether the block is protected as an immutable prefix.

Source

pub fn eviction_candidate( &self, candidates: impl IntoIterator<Item = CacheBlockId>, required: Option<&CacheBlockId>, recent_per_layer: usize, policy: CacheEvictionPolicy, ) -> Result<Option<CacheBlockId>, CacheLifecycleError>

Selects one eviction victim from backend-supplied physically eligible IDs.

Source

pub fn recent_protection_counts( &self, candidates: impl IntoIterator<Item = CacheBlockId>, recent_per_layer: usize, ) -> Result<BTreeMap<usize, u64>, CacheLifecycleError>

Counts unprotected blocks retained by a per-layer recent window.

Source

pub fn set_tail( &mut self, layer: usize, tail: MutableCacheTail, ) -> Option<MutableCacheTail>

Replaces one layer’s mutable tail, returning the prior state for rollback.

Source

pub fn restore_tail(&mut self, layer: usize, tail: Option<MutableCacheTail>)

Restores a prior tail after a failed backend admission.

Source

pub fn tail(&self, layer: usize) -> Option<MutableCacheTail>

Returns one layer’s mutable tail.

Source

pub fn tails(&self) -> impl Iterator<Item = (usize, MutableCacheTail)> + '_

Iterates mutable tails in stable layer order.

Source

pub fn clear(&mut self) -> Result<(), CacheLifecycleError>

Clears all blocks and tails only when no lease is active.

Trait Implementations§

Source§

impl Debug for CacheBlockLifecycle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CacheBlockLifecycle

Source§

fn default() -> CacheBlockLifecycle

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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.