pub struct AckLedger { /* private fields */ }Expand description
Tracks what has been sent and not yet acknowledged.
The point of a ledger rather than an await is that nothing blocks: a peer that never
answers produces an AckOutcome::TimedOut, not a stalled task. That is the deadlock
[s2-json #22] describes, designed out.
Implementations§
Source§impl AckLedger
impl AckLedger
Sourcepub fn new(max_answered: usize) -> Self
pub fn new(max_answered: usize) -> Self
A ledger that remembers the last max_answered inbound identifiers.
Sourcepub fn sent(
&mut self,
handle: MessageHandle,
sent_at: Timestamp,
deadline: Timestamp,
)
pub fn sent( &mut self, handle: MessageHandle, sent_at: Timestamp, deadline: Timestamp, )
Record an outbound message that expects an acknowledgement.
Sourcepub fn received(
&mut self,
status: &ReceptionStatus,
now: Timestamp,
) -> AckOutcome
pub fn received( &mut self, status: &ReceptionStatus, now: Timestamp, ) -> AckOutcome
Match an inbound ReceptionStatus to what it answers.
Sourcepub fn expire(&mut self, now: Timestamp) -> Vec<MessageHandle>
pub fn expire(&mut self, now: Timestamp) -> Vec<MessageHandle>
Everything whose deadline has passed.
Sourcepub fn next_deadline(&self) -> Option<Timestamp>
pub fn next_deadline(&self) -> Option<Timestamp>
The earliest deadline still outstanding.
Sourcepub fn outstanding(&self) -> usize
pub fn outstanding(&self) -> usize
How many messages are waiting.
Sourcepub fn answered(&mut self, id: Id, status: ReceptionStatusValues)
pub fn answered(&mut self, id: Id, status: ReceptionStatusValues)
Remember how an inbound message was answered.
Sourcepub fn previous_answer(&self, id: Id) -> Option<ReceptionStatusValues>
pub fn previous_answer(&self, id: Id) -> Option<ReceptionStatusValues>
How an inbound message was answered before, if it has been seen.
Trait Implementations§
Auto Trait Implementations§
impl Forget for AckLedger
impl Freeze for AckLedger
impl Move for AckLedger
impl RefUnwindSafe for AckLedger
impl Send for AckLedger
impl Sync for AckLedger
impl Unpin for AckLedger
impl UnsafeUnpin for AckLedger
impl UnwindSafe for AckLedger
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
Mutably borrows from an owned value. Read more