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 Freeze for Scheduler
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.