pub struct PendingAckQueue { /* private fields */ }Expand description
Fixed-capacity circular buffer of pending acks. Decouples TCP receives
from journal fsync by allowing up to cap batches to be submitted to
the journal stage before any ack is sent. Acks are flushed in FIFO
order as the journal cursor advances.
Box<[PendingAck]> rather than Vec<PendingAck>: the capacity is
fixed at construction; a slice avoids the Vec’s capacity field on
every push/pop. cap is constrained to a power of two so the
modulo on head + len lowers to a single AND.
Implementations§
Source§impl PendingAckQueue
impl PendingAckQueue
Sourcepub fn new(cap: usize) -> PendingAckQueue
pub fn new(cap: usize) -> PendingAckQueue
cap must be a power of two and ≥ 1.
pub fn is_full(&self) -> bool
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Sourcepub fn push(&mut self, journal_target: u64, acked_sequence: u64)
pub fn push(&mut self, journal_target: u64, acked_sequence: u64)
Record a pending ack. Caller must ensure !is_full().
Sourcepub fn pop_ready(
&mut self,
journal_cursor: &CachePadded<Atomic<u64>>,
) -> Option<u64>
pub fn pop_ready( &mut self, journal_cursor: &CachePadded<Atomic<u64>>, ) -> Option<u64>
Pop acks for all batches where the journal cursor has caught up.
Non-blocking — returns None immediately if the oldest pending
batch isn’t durable yet. Returns the highest acked sequence
among the flushed entries.
Sourcepub fn pop_oldest_blocking(
&mut self,
journal_cursor: &CachePadded<Atomic<u64>>,
busy_spin: bool,
) -> u64
pub fn pop_oldest_blocking( &mut self, journal_cursor: &CachePadded<Atomic<u64>>, busy_spin: bool, ) -> u64
Block until the oldest pending ack is durable, then pop all ready entries. Returns the highest acked sequence.
Sourcepub fn pop_all_blocking(
&mut self,
journal_cursor: &CachePadded<Atomic<u64>>,
busy_spin: bool,
) -> Option<u64>
pub fn pop_all_blocking( &mut self, journal_cursor: &CachePadded<Atomic<u64>>, busy_spin: bool, ) -> Option<u64>
Block until ALL pending acks are durable. Returns the highest
acked sequence, or None if the queue was already empty.