pub struct AckTracker { /* private fields */ }Expand description
Thread-safe cumulative ACK tracker with waker notifications.
In Go-Back-N (and ResendSP), ACKs are cumulative. When receiving multiple
in-order frames in rapid succession, AckTracker maintains the latest
session ID and highest acknowledged sequence number. This prevents reverse-path
flooding (e.g. queueing hundreds of redundant individual ACK frames) and
ensures the writer task is immediately woken up to emit the cumulative ACK.
Both session_id and seq (along with the pending ACK flag) are packed
into a single atomic u64 to prevent mixed-state torn reads between concurrent
set_ack and take_ack calls.
Implementations§
Source§impl AckTracker
impl AckTracker
Sourcepub fn set_ack(&self, session_id: u32, seq: u8)
pub fn set_ack(&self, session_id: u32, seq: u8)
Records a new cumulative ACK for session_id up to seq and notifies any waiting writer.
Sourcepub fn take_ack(&self) -> Option<(u32, u8)>
pub fn take_ack(&self) -> Option<(u32, u8)>
Retrieves and clears the latest cumulative ACK if one is pending.
Sourcepub fn register_waker(&self, cx: &mut Context<'_>)
pub fn register_waker(&self, cx: &mut Context<'_>)
Registers the current task waker to be notified when a new ACK is recorded.