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>
impl<S: 'static, Store: SlabStore<Item = WheelEntry<S>>> TimerInstaller<S, Store>
Sourcepub fn new(wheel: TimerWheel<S, Store>) -> Self
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>
impl<S, Store> Installer for TimerInstaller<S, Store>
Source§type Poller = TimerPoller<S, Store>
type Poller = TimerPoller<S, Store>
The concrete poller returned after installation.
Source§fn install(self, world: &mut WorldBuilder) -> TimerPoller<S, Store>
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> 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