[][src]Trait hierarchical_hash_wheel_timer::ClosureTimer

pub trait ClosureTimer: Timer {
    fn schedule_action_once<F>(
        &mut self,
        id: Self::Id,
        timeout: Duration,
        action: F
    )
    where
        F: FnOnce(Self::Id) + Send + 'static
;
fn schedule_action_periodic<F>(
        &mut self,
        id: Self::Id,
        delay: Duration,
        period: Duration,
        action: F
    )
    where
        F: FnMut(Self::Id) -> TimerReturn<()> + Send + 'static
; }

This trait is a convenience API for timers that use the closure state types, i.e. OneShotClosureState and PeriodicClosureState.

Required methods

fn schedule_action_once<F>(
    &mut self,
    id: Self::Id,
    timeout: Duration,
    action: F
) where
    F: FnOnce(Self::Id) + Send + 'static, 

Schedule the action to be executed once after the timeout expires

Note

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

fn schedule_action_periodic<F>(
    &mut self,
    id: Self::Id,
    delay: Duration,
    period: Duration,
    action: F
) where
    F: FnMut(Self::Id) -> TimerReturn<()> + Send + 'static, 

Schedule the action to be run every timeout time units

The first time, the action will be run after delay expires, and then again every timeout time units after.

Note

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

Loading content...

Implementors

impl<I, T> ClosureTimer for T where
    I: Hash + Clone + Eq,
    T: Timer<Id = I, OneshotState = OneShotClosureState<I>, PeriodicState = PeriodicClosureState<I>>, 
[src]

Loading content...