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>
impl<T: BlockMetadata + Sync> BlockManager<T>
Sourcepub fn builder() -> BlockManagerConfigBuilder<T>
pub fn builder() -> BlockManagerConfigBuilder<T>
Create a new builder for BlockManager.
Sourcepub fn id(&self) -> ManagerId
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.
Sourcepub fn allocate_blocks(&self, count: usize) -> Option<Vec<MutableBlock<T>>>
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.
Sourcepub fn allocate_blocks_with_evictions(
&self,
count: usize,
) -> Option<(Vec<MutableBlock<T>>, Vec<SequenceHash>)>
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.
Sourcepub fn reset_inactive_pool(&self) -> Result<(), BlockManagerResetError>
pub fn reset_inactive_pool(&self) -> Result<(), BlockManagerResetError>
Drain the inactive pool, returning all blocks to the reset pool.
Sourcepub fn register_blocks(
&self,
blocks: Vec<CompleteBlock<T>>,
) -> Vec<ImmutableBlock<T>>
pub fn register_blocks( &self, blocks: Vec<CompleteBlock<T>>, ) -> Vec<ImmutableBlock<T>>
Register a batch of completed blocks.
Sourcepub fn register_block(&self, block: CompleteBlock<T>) -> ImmutableBlock<T>
pub fn register_block(&self, block: CompleteBlock<T>) -> ImmutableBlock<T>
Register a single completed block and return an immutable handle.
Sourcepub fn match_blocks(&self, seq_hash: &[SequenceHash]) -> Vec<ImmutableBlock<T>>
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).
Sourcepub fn scan_matches(
&self,
seq_hashes: &[SequenceHash],
touch: bool,
) -> HashMap<SequenceHash, ImmutableBlock<T>>
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.
Sourcepub fn total_blocks(&self) -> usize
pub fn total_blocks(&self) -> usize
Total number of blocks managed (constant after construction).
Sourcepub fn available_blocks(&self) -> usize
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.
Sourcepub fn block_size(&self) -> usize
pub fn block_size(&self) -> usize
Tokens per block (constant after construction).
Sourcepub fn duplication_policy(&self) -> &BlockDuplicationPolicy
pub fn duplication_policy(&self) -> &BlockDuplicationPolicy
Current duplication policy.
Sourcepub fn block_registry(&self) -> &BlockRegistry
pub fn block_registry(&self) -> &BlockRegistry
Reference to the shared block registry.
Sourcepub fn metrics(&self) -> &Arc<BlockPoolMetrics> ⓘ
pub fn metrics(&self) -> &Arc<BlockPoolMetrics> ⓘ
Reference to the block pool metrics.