Struct native_timer::TimerQueue
source · pub struct TimerQueue { /* private fields */ }Expand description
Wrapper of Windows Timer Queue API
Windows OS provides a default Timer Queue which can be retrieved by using TimerQueue::default. The default queue has 'static lifetime, and can
be assigned as a constant.
let mut count = 0;
let default_queue = TimerQueue::default();
let t = default_queue.schedule_timer(Duration::from_millis(100), Duration::default(), None, || count += 1);
sleep(Duration::from_millis(200));
drop(t);
assert_eq!(count, 1);Implementations§
source§impl TimerQueue
impl TimerQueue
sourcepub fn schedule_timer<'q, 'h, F>(
&'q self,
due: Duration,
period: Duration,
hints: Option<CallbackHint>,
handler: F
) -> Result<Timer<'q, 'h>>where
F: FnMut() + Send + 'h,
pub fn schedule_timer<'q, 'h, F>(
&'q self,
due: Duration,
period: Duration,
hints: Option<CallbackHint>,
handler: F
) -> Result<Timer<'q, 'h>>where
F: FnMut() + Send + 'h,
Schedule a timer, either a one-shot timer, or a periodical timer.
sourcepub fn default() -> &'static TimerQueue
pub fn default() -> &'static TimerQueue
Default OS common timer queue