pub struct Scheduler {
timers: VecDeque<Timer>,
event_proxy: EventLoopProxy<Event>,
}
Expand description
Scheduler tracking all pending timers.
Fields§
§timers: VecDeque<Timer>
§event_proxy: EventLoopProxy<Event>
Implementations§
source§impl Scheduler
impl Scheduler
pub fn new(event_proxy: EventLoopProxy<Event>) -> Self
sourcepub fn update(&mut self) -> Option<Instant>
pub fn update(&mut self) -> Option<Instant>
Process all pending timers.
If there are still timers pending after all ready events have been processed, the closest pending deadline will be returned.
sourcepub fn schedule(
&mut self,
event: Event,
interval: Duration,
repeat: bool,
timer_id: TimerId
)
pub fn schedule( &mut self, event: Event, interval: Duration, repeat: bool, timer_id: TimerId )
Schedule a new event.
sourcepub fn unschedule(&mut self, id: TimerId) -> Option<Timer>
pub fn unschedule(&mut self, id: TimerId) -> Option<Timer>
Cancel a scheduled event.
sourcepub fn unschedule_window(&mut self, window_id: WindowId)
pub fn unschedule_window(&mut self, window_id: WindowId)
Remove all timers scheduled for a window.
This must be called when a window is removed to ensure that timers on intervals do not stick around forever and cause a memory leak.
Auto Trait Implementations§
impl !RefUnwindSafe for Scheduler
impl Send for Scheduler
impl Sync for Scheduler
impl Unpin for Scheduler
impl !UnwindSafe for Scheduler
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more