Skip to main content

TimerQueue

Struct TimerQueue 

Source
pub struct TimerQueue { /* private fields */ }
Expand description

Timer queue — manages scheduled events.

Implementations§

Source§

impl TimerQueue

Source

pub fn new() -> TimerQueue

Source

pub fn add(&mut self, entry: TimerEntry)

Source

pub fn remove(&mut self, predicate: impl Fn(&TimerEvent) -> bool)

Remove all entries matching a predicate.

Source

pub fn schedule_poll(&mut self, peer_id: usize, now: i64, interval: u32)

Schedule a poll for a peer (repeating).

Source

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).

Source

pub fn pop_due(&mut self, now: NtpTs64) -> Vec<TimerEvent>

Pop all due events, advancing repeating entries past now. Returns the events that fired.

Source

pub fn len(&self) -> usize

Get the number of entries.

Source

pub fn is_empty(&self) -> bool

Source

pub fn next_deadline(&self) -> Option<i64>

Get the next absolute deadline (in NTP seconds), or None if no timers.

Source

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).

Source

pub fn iter(&self) -> impl Iterator<Item = &TimerEntry>

Iterate over all entries.

Trait Implementations§

Source§

impl Debug for TimerQueue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for TimerQueue

Source§

fn default() -> TimerQueue

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more