Skip to main content

PendingQueue

Struct PendingQueue 

Source
pub struct PendingQueue { /* private fields */ }
Expand description

Per-thread bounded queue for messages with unknown predecessors.

Each thread has an independent bounded queue with max_pending capacity (NFR-301). Entries expire after ttl seconds. When a thread’s queue is full the oldest entry is evicted. Re-evaluation happens when the caller signals store growth.

Implementations§

Source§

impl PendingQueue

Source

pub fn new(max_pending: usize, ttl: u64) -> Self

Create a new PendingQueue with the given bounds.

Source

pub fn from_policy(policy: &UnknownPredecessorPolicy) -> Self

Create from a Buffer policy. Panics if given Reject.

Source

pub fn enqueue( &mut self, entry: PendingEntry, ) -> Option<(PendingEntry, DropReason)>

Enqueue a pending message. If the thread’s queue is at capacity, the oldest entry is evicted and returned as DropReason::Evicted.

Source

pub fn expire(&mut self, now: u64) -> Vec<(PendingEntry, DropReason)>

Remove and return all entries whose TTL has expired at the given now timestamp.

Source

pub fn re_evaluate<S: MessageStore>( &mut self, store: &S, protocol: &CausalProtocol, ) -> Vec<(PendingEntry, PolicyOutcome)>

Re-evaluate all pending entries against the (grown) store.

Returns entries that now resolve to Accept or Reject. Entries still Unknown remain in the queue.

Caution: this method evaluates every entry against the supplied protocol, regardless of whether the protocol declares a step for the entry’s performative. Since verify_causal returns Valid for performatives the protocol does not constrain, calling this with an unrelated protocol will incorrectly flush entries that are still waiting on their real predecessor. Callers with multiple protocols should prefer PendingQueue::re_evaluate_with, which lets the caller decide per entry.

Source

pub fn re_evaluate_with<F>( &mut self, decide: F, ) -> Vec<(PendingEntry, PolicyOutcome)>

Re-evaluate pending entries with caller-supplied verification.

For each entry, the closure returns Some(VerificationResult) to resolve the entry (or keep it pending on Unknown), or None to indicate “no applicable protocol — leave the entry untouched”. This lets callers compose multiple protocols and skip entries that no installed protocol constrains, avoiding the spurious-Accept hazard described on Self::re_evaluate.

Source

pub fn len(&self) -> usize

Total number of buffered entries across all threads.

Source

pub fn is_empty(&self) -> bool

Whether the queue is empty.

Source

pub fn thread_len(&self, thread: &ThreadId) -> usize

Number of buffered entries for a specific thread.

Source

pub fn max_pending(&self) -> usize

Maximum entries per thread.

Source

pub fn ttl(&self) -> u64

TTL in seconds.

Trait Implementations§

Source§

impl Clone for PendingQueue

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PendingQueue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.