Skip to main content

BlockManager

Struct BlockManager 

Source
pub struct BlockManager<T: BlockMetadata> { /* private fields */ }
Expand description

Manages the full block lifecycle over the unified [BlockStore].

Construct via BlockManager::builder().

Implementations§

Source§

impl<T: BlockMetadata + Sync> BlockManager<T>

Source

pub fn builder() -> BlockManagerConfigBuilder<T>

Create a new builder for BlockManager.

Source

pub fn id(&self) -> ManagerId

Stable, process-unique identifier for this manager’s underlying BlockStore. See crate::ManagerId. Cheap (one field load via the store).

Together with a BlockId this names a specific physical pool slot — the disambiguating runtime address that downstream consumers need after the policy parameter T has been type-erased through crate::LifecyclePinRef.

Source

pub fn allocate_blocks(&self, count: usize) -> Option<Vec<MutableBlock<T>>>

Allocate count mutable blocks, drawing first from the reset pool and then evicting from the inactive pool if needed.

Returns None if fewer than count blocks are available across both pools.

Source

pub fn allocate_blocks_with_evictions( &self, count: usize, ) -> Option<(Vec<MutableBlock<T>>, Vec<SequenceHash>)>

Like allocate_blocks but also reports the SequenceHash of each block evicted from the inactive pool.

Source

pub fn reset_inactive_pool(&self) -> Result<(), BlockManagerResetError>

Drain the inactive pool, returning all blocks to the reset pool.

Source

pub fn register_blocks( &self, blocks: Vec<CompleteBlock<T>>, ) -> Vec<ImmutableBlock<T>>

Register a batch of completed blocks.

Source

pub fn register_block(&self, block: CompleteBlock<T>) -> ImmutableBlock<T>

Register a single completed block and return an immutable handle.

Source

pub fn match_blocks(&self, seq_hash: &[SequenceHash]) -> Vec<ImmutableBlock<T>>

Linear prefix match: walks seq_hash left-to-right, stopping on the first hash that hits neither the active nor the inactive pool.

The whole active-or-inactive prefix is resolved under a single store-mutex acquisition via [BlockStore::match_prefix_locked_batch] — no per-hash registry radix-tree lookup, no per-hash store lock. Frequency-tracker touches are batched and applied after the store lock is released: every returned block is touched exactly once (including inactive resurrections).

Source

pub fn scan_matches( &self, seq_hashes: &[SequenceHash], touch: bool, ) -> HashMap<SequenceHash, ImmutableBlock<T>>

Scatter-gather scan: finds all blocks matching any hash, without stopping on misses.

Source

pub fn total_blocks(&self) -> usize

Total number of blocks managed (constant after construction).

Source

pub fn available_blocks(&self) -> usize

Blocks available for allocation (reset + inactive pools).

Reads both pool sizes under a single store-lock acquisition so the returned value is a coherent snapshot, never an over- or under-count produced by a concurrent reset↔inactive transition.

Source

pub fn block_size(&self) -> usize

Tokens per block (constant after construction).

Source

pub fn duplication_policy(&self) -> &BlockDuplicationPolicy

Current duplication policy.

Source

pub fn block_registry(&self) -> &BlockRegistry

Reference to the shared block registry.

Source

pub fn metrics(&self) -> &Arc<BlockPoolMetrics>

Reference to the block pool metrics.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for BlockManager<T>

§

impl<T> !UnwindSafe for BlockManager<T>

§

impl<T> Freeze for BlockManager<T>

§

impl<T> Send for BlockManager<T>

§

impl<T> Sync for BlockManager<T>

§

impl<T> Unpin for BlockManager<T>

§

impl<T> UnsafeUnpin for BlockManager<T>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more