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
impl PendingQueue
Sourcepub fn new(max_pending: usize, ttl: u64) -> Self
pub fn new(max_pending: usize, ttl: u64) -> Self
Create a new PendingQueue with the given bounds.
Sourcepub fn from_policy(policy: &UnknownPredecessorPolicy) -> Self
pub fn from_policy(policy: &UnknownPredecessorPolicy) -> Self
Create from a Buffer policy. Panics if given Reject.
Sourcepub fn enqueue(
&mut self,
entry: PendingEntry,
) -> Option<(PendingEntry, DropReason)>
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.
Sourcepub fn expire(&mut self, now: u64) -> Vec<(PendingEntry, DropReason)>
pub fn expire(&mut self, now: u64) -> Vec<(PendingEntry, DropReason)>
Remove and return all entries whose TTL has expired at the given now timestamp.
Sourcepub fn re_evaluate<S: MessageStore>(
&mut self,
store: &S,
protocol: &CausalProtocol,
) -> Vec<(PendingEntry, PolicyOutcome)>
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.
Sourcepub fn re_evaluate_with<F>(
&mut self,
decide: F,
) -> Vec<(PendingEntry, PolicyOutcome)>
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.
Sourcepub fn thread_len(&self, thread: &ThreadId) -> usize
pub fn thread_len(&self, thread: &ThreadId) -> usize
Number of buffered entries for a specific thread.
Sourcepub fn max_pending(&self) -> usize
pub fn max_pending(&self) -> usize
Maximum entries per thread.