Struct libuv::handles::timer::TimerHandle
source · pub struct TimerHandle { /* private fields */ }
Expand description
Timer handles are used to schedule callbacks to be called in the future.
Implementations§
source§impl TimerHandle
impl TimerHandle
sourcepub fn new(loop: &Loop) -> Result<TimerHandle>
pub fn new(loop: &Loop) -> Result<TimerHandle>
Create and initialize a new timer handle
sourcepub fn start<CB: Into<TimerCB<'static>>>(
&mut self,
timeout: u64,
repeat: u64,
cb: CB
) -> Result<()>
pub fn start<CB: Into<TimerCB<'static>>>( &mut self, timeout: u64, repeat: u64, cb: CB ) -> Result<()>
Start the timer. timeout and repeat are in milliseconds.
If timeout is zero, the callback fires on the next event loop iteration. If repeat is non-zero, the callback fires first after timeout milliseconds and then repeatedly after repeat milliseconds.
Note: Does not update the event loop’s concept of “now”. See Loop.update_time() for more information.
If the timer is already active, it is simply updated.
sourcepub fn again(&mut self) -> Result<()>
pub fn again(&mut self) -> Result<()>
Stop the timer, and if it is repeating restart it using the repeat value as the timeout. If the timer has never been started before it returns EINVAL.
sourcepub fn set_repeat(&mut self, repeat: u64)
pub fn set_repeat(&mut self, repeat: u64)
Set the repeat interval value in milliseconds. The timer will be scheduled to run on the given interval, regardless of the callback execution duration, and will follow normal timer semantics in the case of a time-slice overrun.
For example, if a 50ms repeating timer first runs for 17ms, it will be scheduled to run again 33ms later. If other tasks consume more than the 33ms following the first timer callback, then the callback will run as soon as possible.
Note: If the repeat value is set from a timer callback it does not immediately take effect. If the timer was non-repeating before, it will have been stopped. If it was repeating, then the old repeat value will have been used to schedule the next timeout.
sourcepub fn get_repeat(&self) -> u64
pub fn get_repeat(&self) -> u64
Get the timer repeat value.
Trait Implementations§
source§impl Clone for TimerHandle
impl Clone for TimerHandle
source§fn clone(&self) -> TimerHandle
fn clone(&self) -> TimerHandle
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more