Struct veloren_common::clock::Clock
source · pub struct Clock {
target_dt: Duration,
last_sys_time: Instant,
last_dt: Duration,
total_tick_time: Duration,
last_dts: VecDeque<NotNan<f32>>,
last_dts_sorted: Vec<NotNan<f32>>,
last_busy_dts: VecDeque<NotNan<f32>>,
stats: ClockStats,
}
Expand description
This Clock tries to make this tick a constant time by sleeping the rest of the tick
- if we actually took less time than we planned: sleep and return planned time
- if we ran behind: don’t sleep and return actual time
We DON’T do any fancy averaging of the deltas for tick for 2 reasons:
- all Systems have to work based on
dt
and we cannot assume that this is const through all ticks - when we have a slow tick, a lag, it doesn’t help that we have 10 fast ticks directly afterwards
We return a smoothed version for display only!
Fields§
§target_dt: Duration
This is the dt that the Clock tries to archive with each call of tick.
last_sys_time: Instant
Last time tick
was called
last_dt: Duration
Will be calculated in tick
returns the dt used by the next iteration
of the main loop
total_tick_time: Duration
Summed up last_dt
last_dts: VecDeque<NotNan<f32>>
§last_dts_sorted: Vec<NotNan<f32>>
§last_busy_dts: VecDeque<NotNan<f32>>
§stats: ClockStats
Implementations§
Auto Trait Implementations§
impl Freeze for Clock
impl RefUnwindSafe for Clock
impl Send for Clock
impl Sync for Clock
impl Unpin for Clock
impl UnwindSafe for Clock
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more