[−][src]Struct hjul::Runner
Methods
impl Runner
[src]
pub fn new(tick: Duration, slots: usize, capacity: usize) -> Runner
[src]
Creates a new Runner, which executes the associated timer callbacks
Arguments
tick
: duration of a single tick. This determines the accuracy of the underlaying timer wheelslots
: Number of slots in the timer wheel.capacity
: Maximum number of timers which can be allocated for the wheel
Note
The longest possible duration of any timer is tick
* slots
Example
use hjul::Runner; use std::time::Duration; // allows 1024 timers, with duration up to 10s and 100ms accuracy let runner = Runner::new(Duration::from_millis(100), 100, 1024);
pub fn timer<F>(&self, callback: F) -> Timer where
F: 'static + Fn() + Send + Sync,
[src]
F: 'static + Fn() + Send + Sync,
Allocate a new (stopped) timer and associate it with the callback
Arguments
callback
: Callback to execute whenever the timer fires (possible repeatedly, if reset).
Example
let timer = runner.timer(|| println!("fired")); // start the timer timer.reset(Duration::from_millis(100)); // wait for timer to fire thread::sleep(Duration::from_millis(1000));
Trait Implementations
Auto Trait Implementations
impl Send for Runner
impl Sync for Runner
impl Unpin for Runner
impl !RefUnwindSafe for Runner
impl !UnwindSafe for Runner
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,