pub struct CapacityTracker { /* private fields */ }Expand description
Per-consumer tracker for current in-flight and buffered message counts.
Implementations§
Source§impl CapacityTracker
impl CapacityTracker
Sourcepub const fn new(capacity: ConsumerCapacity) -> Self
pub const fn new(capacity: ConsumerCapacity) -> Self
Creates a tracker for an explicitly declared consumer capacity.
Sourcepub const fn derived(capacity: ConsumerCapacity, queued: usize) -> Self
pub const fn derived(capacity: ConsumerCapacity, queued: usize) -> Self
Builds a tracker whose two bands are DERIVED from queued — the
authoritative depth of the queue the messages actually sit in —
rather than accumulated by independent record_* mutations
(A1 §0.1/§2, docs/design/A1-DEFER-SEMANTICS.md).
The in-flight band is min(queued, max_in_flight) and the buffered
band is queued.saturating_sub(max_in_flight), so the occupancy
invariant queued == current_in_flight + current_buffer_depth
holds for EVERY queued, and neither band can be decremented below
zero because neither band is ever decremented at all. That is what
retires the CapacityError::InFlightUnderflow /
CapacityError::BufferUnderflow drift class by construction: the
hot path calls this constructor and reads
Self::pressure_signal, and never touches a record_* mutator.
The mutators stay for the explicit-credit (v2) accounting the design specifies but does not ship, and for the standalone unit tests already written against them.
Sourcepub const fn capacity(&self) -> &ConsumerCapacity
pub const fn capacity(&self) -> &ConsumerCapacity
Returns the consumer capacity declaration this tracker follows.
Sourcepub const fn current_in_flight(&self) -> usize
pub const fn current_in_flight(&self) -> usize
Returns the number of messages currently being processed by the consumer.
Sourcepub const fn current_buffer_depth(&self) -> usize
pub const fn current_buffer_depth(&self) -> usize
Returns the number of messages currently buffered for the consumer.
Sourcepub const fn record_delivery(&mut self)
pub const fn record_delivery(&mut self)
Records that a message was delivered and processing began.
Sourcepub const fn record_completion(&mut self) -> Result<(), CapacityError>
pub const fn record_completion(&mut self) -> Result<(), CapacityError>
Records that processing completed for one in-flight message.
§Errors
Returns CapacityError::InFlightUnderflow if no message is currently in flight.
Sourcepub const fn record_buffered(&mut self)
pub const fn record_buffered(&mut self)
Records that a message was buffered pending consumer capacity.
Sourcepub const fn record_buffer_drained(&mut self) -> Result<(), CapacityError>
pub const fn record_buffer_drained(&mut self) -> Result<(), CapacityError>
Records that one buffered message left the buffer.
§Errors
Returns CapacityError::BufferUnderflow if no message is currently buffered.
Sourcepub const fn pressure_signal(&self) -> PressureSignal
pub const fn pressure_signal(&self) -> PressureSignal
Determines the pressure signal for the next message without mutating counters.
Trait Implementations§
Source§impl Clone for CapacityTracker
impl Clone for CapacityTracker
Source§fn clone(&self) -> CapacityTracker
fn clone(&self) -> CapacityTracker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CapacityTracker
impl Debug for CapacityTracker
impl Eq for CapacityTracker
Source§impl PartialEq for CapacityTracker
impl PartialEq for CapacityTracker
impl StructuralPartialEq for CapacityTracker
Auto Trait Implementations§
impl Freeze for CapacityTracker
impl RefUnwindSafe for CapacityTracker
impl Send for CapacityTracker
impl Sync for CapacityTracker
impl Unpin for CapacityTracker
impl UnsafeUnpin for CapacityTracker
impl UnwindSafe for CapacityTracker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.