pub struct DelayQueue {
conf: Arc<Config>,
items: BTreeMap<(Slot, MsgId), RetryItem>,
ready: BTreeMap<(Slot, MsgId), Bytes>,
}Fields§
§conf: Arc<Config>§items: BTreeMap<(Slot, MsgId), RetryItem>All items that need to be resend at some point.
ready: BTreeMap<(Slot, MsgId), Bytes>Items that are due and should be sent asap.
Implementations§
Source§impl DelayQueue
impl DelayQueue
pub fn new(c: Arc<Config>) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn is_ready(&self) -> bool
pub fn add(&mut self, s: Slot, i: MsgId, b: Bytes)
pub fn del(&mut self, s: Slot, i: MsgId)
pub fn reset(&mut self)
Sourcepub fn check(&mut self, now: Instant)
pub fn check(&mut self, now: Instant)
Scan all items to find the next ones that are due.
Scanning stops when a READY_BATCH is full. Since scanning happens
less frequently (about once per second) and is O(n) in the worst case,
we make several items that are due available for quick access.
pub fn gc(&mut self, s: Slot)
Auto Trait Implementations§
impl Freeze for DelayQueue
impl !RefUnwindSafe for DelayQueue
impl Send for DelayQueue
impl Sync for DelayQueue
impl Unpin for DelayQueue
impl UnsafeUnpin for DelayQueue
impl !UnwindSafe for DelayQueue
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