Skip to main content

TimerPoller

Struct TimerPoller 

Source
pub struct TimerPoller<S = Box<dyn Handler<Instant>>, Store = UnboundedSlab<WheelEntry<S>>> { /* private fields */ }
Expand description

Timer driver poller — generic over handler storage and slab store.

Returned by TimerInstaller::install. Holds a pre-resolved ResourceId for the wheel and a reusable drain buffer.

Store is the slab backend — determines which TimerWheel<S, Store> resource to look up in the World. Defaults to the unbounded slab.

Implementations§

Source§

impl<S, Store> TimerPoller<S, Store>
where S: DerefMut + Send + 'static, S::Target: Handler<Instant>, Store: SlabStore<Item = WheelEntry<S>> + 'static,

Source

pub fn poll(&mut self, world: &mut World, now: Instant) -> usize

Poll expired timers — drain from wheel, fire each handler, done.

Each handler receives now as its event. Handlers that need to reschedule themselves do so directly via the wheel resource.

Returns the number of timers fired.

Source

pub fn next_deadline(&self, world: &World) -> Option<Instant>

Earliest deadline in the wheel.

Source

pub fn len(&self, world: &World) -> usize

Number of active timers.

Source

pub fn is_empty(&self, world: &World) -> bool

Whether the wheel is empty.

Trait Implementations§

Source§

impl<S, Store> Debug for TimerPoller<S, Store>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S, Store> Freeze for TimerPoller<S, Store>

§

impl<S, Store> RefUnwindSafe for TimerPoller<S, Store>
where S: RefUnwindSafe,

§

impl<S, Store> Send for TimerPoller<S, Store>
where S: Send,

§

impl<S = Box<dyn Handler<Instant>>, Store = Slab<WheelEntry<S>>> !Sync for TimerPoller<S, Store>

§

impl<S, Store> Unpin for TimerPoller<S, Store>
where S: Unpin,

§

impl<S, Store> UnsafeUnpin for TimerPoller<S, Store>

§

impl<S, Store> UnwindSafe for TimerPoller<S, Store>
where S: UnwindSafe,

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.