Struct riddle_time::TimeSystem[][src]

pub struct TimeSystem { /* fields omitted */ }

The Riddle time system core state.

Manages tracking framerate and timer state.

It is possible to manage the audio system state independantly - the most important thing to note is that ext::TimeSystemExt::process_frame must be called once per “frame”. The default Riddle integration calls that method whenever the riddle::Event::ProcessFrame event is fired.

Implementations

impl TimeSystem[src]

pub fn fps(&self) -> f32[src]

Get the current FPS as calculated based on previous frame durations.

pub fn delta_secs(&self) -> f32[src]

Get the current delta t as calculated based on previous frame durations.

pub fn frame_instant(&self) -> Instant[src]

Get the reference time for this frame. Captured during ext::TimeSystemExt::process_frame.

pub fn register_timer<F>(&self, duration: Duration, callback: F) -> TimerHandle where
    F: FnOnce() + Send + 'static, 
[src]

Register a timer with a callback which will be fired when the time elpases.

The returned handle may be dropped without cancelling the timer.

Example

let val = Arc::new(AtomicBool::new(false));

time_system.register_timer(std::time::Duration::from_millis(200), {
    let val = val.clone();
    move || { val.store(true, Ordering::Relaxed); }
});

// A while later
assert_eq!(true, val.load(Ordering::Relaxed));

Trait Implementations

impl CloneHandle for TimeSystem[src]

type Handle = TimeSystemHandle

The type which represents a strong reference, and which may be dereferenced as Self. Read more

type WeakHandle = TimeSystemWeak

The type which represents a weak reference.

impl TimeSystemExt for TimeSystem[src]

Auto Trait Implementations

impl RefUnwindSafe for TimeSystem

impl Send for TimeSystem

impl Sync for TimeSystem

impl Unpin for TimeSystem

impl UnwindSafe for TimeSystem

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.