pub struct TimerQueue { /* private fields */ }Expand description
Timer queue — manages scheduled events.
Implementations§
Source§impl TimerQueue
impl TimerQueue
pub fn new() -> TimerQueue
pub fn add(&mut self, entry: TimerEntry)
Sourcepub fn remove(&mut self, predicate: impl Fn(&TimerEvent) -> bool)
pub fn remove(&mut self, predicate: impl Fn(&TimerEvent) -> bool)
Remove all entries matching a predicate.
Sourcepub fn schedule_poll(&mut self, peer_id: usize, now: i64, interval: u32)
pub fn schedule_poll(&mut self, peer_id: usize, now: i64, interval: u32)
Schedule a poll for a peer (repeating).
Sourcepub fn schedule_poll_once(&mut self, peer_id: usize, due: i64)
pub fn schedule_poll_once(&mut self, peer_id: usize, due: i64)
Schedule a single one-shot poll for a peer (interval=0, dropped after firing).
Sourcepub fn pop_due(&mut self, now: NtpTs64) -> Vec<TimerEvent>
pub fn pop_due(&mut self, now: NtpTs64) -> Vec<TimerEvent>
Pop all due events, advancing repeating entries past now.
Returns the events that fired.
pub fn is_empty(&self) -> bool
Sourcepub fn next_deadline(&self) -> Option<i64>
pub fn next_deadline(&self) -> Option<i64>
Get the next absolute deadline (in NTP seconds), or None if no timers.
Sourcepub fn poll_timeout_ms(&self, now_seconds: i64) -> i32
pub fn poll_timeout_ms(&self, now_seconds: i64) -> i32
Get the deadline as a millisecond timeout suitable for poll/epoll. Returns -1 (infinite) when there are no timers, or the timeout in ms (capped at 0 minimum — never return a negative timeout for poll).
Sourcepub fn iter(&self) -> impl Iterator<Item = &TimerEntry>
pub fn iter(&self) -> impl Iterator<Item = &TimerEntry>
Iterate over all entries.
Trait Implementations§
Source§impl Debug for TimerQueue
impl Debug for TimerQueue
Source§impl Default for TimerQueue
impl Default for TimerQueue
Source§fn default() -> TimerQueue
fn default() -> TimerQueue
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TimerQueue
impl RefUnwindSafe for TimerQueue
impl Send for TimerQueue
impl Sync for TimerQueue
impl Unpin for TimerQueue
impl UnsafeUnpin for TimerQueue
impl UnwindSafe for TimerQueue
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