pub struct ImmutableBlock<T: BlockMetadata> { /* private fields */ }Expand description
RAII guard for a block in the Registered state.
Clone increments an Arc and the inflight_immutable metric;
dropping a clone decrements the metric. Dropping the last strong
reference triggers the slot’s transition to Inactive (primary) or
Reset (duplicate).
Implementations§
Source§impl<T: BlockMetadata + Sync> ImmutableBlock<T>
impl<T: BlockMetadata + Sync> ImmutableBlock<T>
Sourcepub fn downgrade(&self) -> WeakBlock<T>
pub fn downgrade(&self) -> WeakBlock<T>
Creates a WeakBlock that does not prevent the block from being
evicted.
Sourcepub fn sequence_hash(&self) -> SequenceHash
pub fn sequence_hash(&self) -> SequenceHash
Returns the SequenceHash that identifies this block’s content.
Sourcepub fn registration_handle(&self) -> BlockRegistrationHandle
pub fn registration_handle(&self) -> BlockRegistrationHandle
Returns a clone of the BlockRegistrationHandle for this block.
Sourcepub fn use_count(&self) -> usize
pub fn use_count(&self) -> usize
Returns the number of strong Arc references to the underlying
inner.
Sourcepub fn set_evict_on_reset(&self, value: bool)
pub fn set_evict_on_reset(&self, value: bool)
Set the per-block “reset on release” override.
When the last clone of this block drops, the slot transitions to
the reset/free list (true) or to the inactive cache (false),
overriding the store-wide default set by
BlockManagerConfigBuilder::with_default_reset_on_release.
The override is sticky across cache-hit resurrections: if the
block lands in the inactive pool and is later matched, the
resurrected ImmutableBlock inherits this value. The override
is reset to the store-wide default only when the slot truly
leaves the inactive pool (eviction back to Mutable).
Briefly acquires the store mutex to publish the write. Not a hot path — typically called at most once per block. Concurrent setters race with last-writer-wins semantics under the mutex.
Race-window guarantee: the override is preserved even when a
concurrent match_blocks drives the eager Primary → Inactive
transition (because this Inner’s Arc strong-count went to 0
before release_primary ran). The eager path leaves the
per-slot value untouched, and every reader of that value also
goes through the same store mutex — so visibility comes from
release-acquire on the mutex, not from any assumption about
Arc::drop / Weak::upgrade ordering.
Sourcepub fn pin(&self) -> LifecyclePinRef
pub fn pin(&self) -> LifecyclePinRef
Type-erased lifecycle pin for cross-policy use.
Returns an LifecyclePinRef that:
- Bumps the underlying
Arc<ImmutableBlockInner<T>>once (the only allocation cost is oneArc::clone— noBoxand no new heap node). - Keeps the slot alive (preventing the
Active → Inactivetransition) while the pin is live, identical to holding anImmutableBlockclone. - Exposes
(manager_id, block_id, sequence_hash)so callers that stash a heterogeneous list of pins (differentTs) can still address each slot unambiguously at runtime.
See [crate::blocks::pin] for the rationale.