Skip to main content

PendingAckQueue

Struct PendingAckQueue 

Source
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

Source

pub fn new(cap: usize) -> PendingAckQueue

cap must be a power of two and ≥ 1.

Source

pub fn is_full(&self) -> bool

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn push(&mut self, journal_target: u64, acked_sequence: u64)

Record a pending ack. Caller must ensure !is_full().

Source

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.

Source

pub fn pop_oldest_blocking( &mut self, journal_cursor: &CachePadded<Atomic<u64>>, busy_spin: bool, abort: &Atomic<bool>, ) -> Option<u64>

Block until the oldest pending ack is durable, then pop all ready entries. Returns the highest acked sequence, or None if abort flipped while waiting — the journal stage has died and the cursor will never advance; the caller must tear the session down instead of waiting forever.

Source

pub fn pop_all_blocking( &mut self, journal_cursor: &CachePadded<Atomic<u64>>, busy_spin: bool, abort: &Atomic<bool>, ) -> Option<u64>

Block until ALL pending acks are durable (or abort flips). Returns the highest acked sequence, or None if the queue was already empty or the first wait aborted.

Auto Trait Implementations§

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

Source§

type Output = T

Should always be Self
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