Skip to main content

TimerInstaller

Struct TimerInstaller 

Source
pub struct TimerInstaller<S: 'static = Box<dyn Handler<Instant>>, Store: SlabStore<Item = WheelEntry<S>> = UnboundedSlab<WheelEntry<S>>> { /* private fields */ }
Expand description

Timer driver installer — takes a pre-built TimerWheel.

Build the wheel via WheelBuilder, then hand it to the installer. The installer registers it into the World and returns a TimerPoller for poll-time use.

§Examples

use std::time::{Duration, Instant};
use nexus_rt::{TimerInstaller, TimerPoller, BoundedTimerPoller, WheelBuilder};

// Unbounded — slab grows as needed, scheduling never fails
let wheel = WheelBuilder::default().unbounded(64).build(Instant::now());
let timer: TimerPoller = wb.install_driver(TimerInstaller::new(wheel));

// Bounded — fixed capacity, try_schedule returns Err(Full) when full
let wheel = WheelBuilder::default().bounded(1024).build(Instant::now());
let timer: BoundedTimerPoller = wb.install_driver(TimerInstaller::new(wheel));

// Custom tick resolution for microsecond-precision timers
let wheel = WheelBuilder::default()
    .tick_duration(Duration::from_micros(100))
    .unbounded(256)
    .build(Instant::now());
let timer: TimerPoller = wb.install_driver(TimerInstaller::new(wheel));

Implementations§

Source§

impl<S: 'static, Store: SlabStore<Item = WheelEntry<S>>> TimerInstaller<S, Store>

Source

pub fn new(wheel: TimerWheel<S, Store>) -> Self

Creates a timer installer from a pre-built wheel.

Build the wheel via WheelBuilder, then pass it here.

Trait Implementations§

Source§

impl<S, Store> Installer for TimerInstaller<S, Store>
where S: Send + 'static, Store: SlabStore<Item = WheelEntry<S>> + 'static,

Source§

type Poller = TimerPoller<S, Store>

The concrete poller returned after installation.
Source§

fn install(self, world: &mut WorldBuilder) -> TimerPoller<S, Store>

Register resources into the world and return a poller for dispatch.

Auto Trait Implementations§

§

impl<S, Store> Freeze for TimerInstaller<S, Store>
where Store: Freeze,

§

impl<S = Box<dyn Handler<Instant>>, Store = Slab<WheelEntry<S>>> !RefUnwindSafe for TimerInstaller<S, Store>

§

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

§

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

§

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

§

impl<S, Store> UnsafeUnpin for TimerInstaller<S, Store>
where Store: UnsafeUnpin,

§

impl<S = Box<dyn Handler<Instant>>, Store = Slab<WheelEntry<S>>> !UnwindSafe for TimerInstaller<S, Store>

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.