[][src]Trait hierarchical_hash_wheel_timer::Timer

pub trait Timer {
    type Id: Hash + Clone + Eq;
    type OneshotState: OneshotState<Id = Self::Id>;
    type PeriodicState: PeriodicState<Id = Self::Id>;
    fn schedule_once(&mut self, timeout: Duration, state: Self::OneshotState);
fn schedule_periodic(
        &mut self,
        delay: Duration,
        period: Duration,
        state: Self::PeriodicState
    );
fn cancel(&mut self, id: &Self::Id); }

A basic low-level timer API

This allows behaviours to be scheduled for later execution.

Associated Types

type Id: Hash + Clone + Eq

A type to uniquely identify any timeout to be schedulled or cancelled

type OneshotState: OneshotState<Id = Self::Id>

The type of state to keep for oneshot timers

type PeriodicState: PeriodicState<Id = Self::Id>

The type of state to keep for periodic timers

Loading content...

Required methods

fn schedule_once(&mut self, timeout: Duration, state: Self::OneshotState)

Schedule the state to be triggered once after the timeout expires

Note

Depending on your system and the implementation used, there is always a certain lag between the triggering of the state and the timeout expiring on the system's clock. Thus it is only guaranteed that the state is not triggered before the timeout expires, but no bounds on the lag are given.

fn schedule_periodic(
    &mut self,
    delay: Duration,
    period: Duration,
    state: Self::PeriodicState
)

Schedule the state to be triggered every timeout time units

The first time, the state will be trigerreed after delay expires, and then again every timeout time units after, unless the TimerReturn given specifies otherwise.

Note

Depending on your system and the implementation used, there is always a certain lag between the triggering of the state and the timeout expiring on the system's clock. Thus it is only guaranteed that the state is not triggered before the timeout expires, but no bounds on the lag are given.

fn cancel(&mut self, id: &Self::Id)

Cancel the timer indicated by the unique id

Loading content...

Implementors

impl<I, O, P> Timer for SimulationTimer<I, O, P> where
    I: Hash + Clone + Eq + Debug,
    O: OneshotState<Id = I> + Debug,
    P: PeriodicState<Id = I> + Debug
[src]

type Id = I

type OneshotState = O

type PeriodicState = P

impl<I, O, P> Timer for TimerRef<I, O, P> where
    I: Hash + Clone + Eq,
    O: OneshotState<Id = I>,
    P: PeriodicState<Id = I>, 
[src]

type Id = I

type OneshotState = O

type PeriodicState = P

Loading content...