pub struct TickPacer { /* private fields */ }Expand description
Paces a fixed-rate tick loop against the wall clock, one pass at a time.
A frontend alternates between handling input and running the ticks that are due. Each pass
reads the clock once and runs the ticks owed at that instant, however long they take to run;
whatever falls due meanwhile waits for the next pass, after the frontend has handled the input
that arrived in between — a key release, Esc, a resize. A pass that asked the clock again
after every tick would keep finding another one due for as long as ticks run slower than real
time (a heavy cart, an unoptimized build), and would never hand control back.
Implementations§
Source§impl TickPacer
impl TickPacer
Sourcepub fn tick_due(&mut self, now: Instant, frame: Duration) -> bool
pub fn tick_due(&mut self, now: Instant, frame: Duration) -> bool
Whether a tick is due by now, the instant the calling pass began, counting it as run if
so.
A pass asks with the same now until the answer is false, running one tick per true.
A pass still more than ten frames behind after its first tick drops the rest of the
backlog rather than running it back to back: that tick is all it runs, and the next falls
due a frame after now.
Auto Trait Implementations§
impl Freeze for TickPacer
impl RefUnwindSafe for TickPacer
impl Send for TickPacer
impl Sync for TickPacer
impl Unpin for TickPacer
impl UnsafeUnpin for TickPacer
impl UnwindSafe for TickPacer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.