Skip to main content

SchedulerState

Struct SchedulerState 

Source
pub struct SchedulerState { /* private fields */ }
Expand description

The runtime state of a scheduler instance.

Implementations§

Source§

impl SchedulerState

Implements time retrieval and tick execution for SchedulerState.

Source

pub fn current_time() -> f64

Returns the current high-resolution timestamp in seconds from performance.now().

Falls back to 0.0 when the global window or the performance.now API is unavailable (for example outside a browser window context).

The performance object and its now Function are page-lifetime globals, so they are cached in a thread-local on first use — the per-frame cost is one call0 crossing, not two Reflect::get + two JsValue::from_str allocations.

§Returns
  • f64 - The current time in seconds, or 0.0 when unavailable.
Source

pub fn tick( &mut self, config: &SchedulerConfig, handler: &TickHandlerRc, tasks: Option<&TaskRegistryRc>, input_cell: Option<&InputStateCell>, )

Performs one tick of the fixed-timestep scheduler.

Calculates the elapsed frame time, clamps it to max_frame_time, accumulates it, then runs as many fixed updates as needed. Finally, computes the interpolation factor and calls the render callback. When an input cell is supplied, its per-frame edge state is cleared after the render callback so the next frame observes only the edges that happened during that frame.

Registered tasks are advanced immediately after each handler on_update call, not once per frame: a frame may run several fixed steps, and every one of them must advance the tasks by the same fixed_timestep that gameplay logic receives. Driving tasks after the handler callback keeps ordering explicit — gameplay logic registered in on_update observes tasks that have already advanced for this step.

§Arguments
  • &SchedulerConfig - The scheduler configuration.
  • &TickHandlerRc - The handler receiving update and render callbacks.
  • Option<&TaskRegistryRc> - The task registry to advance each fixed step, or None when no tasks are registered.
  • Option<&InputStateCell> - The shared input state to close out, or None when no input listeners are registered.
Source§

impl SchedulerState

Source

pub fn get_accumulator(&self) -> f64

Source

pub fn get_last_time(&self) -> f64

Source

pub fn get_running(&self) -> bool

Source

pub fn get_raf_id(&self) -> Option<i32>

Source

pub fn try_get_raf_id(&self) -> Option<i32>

Source

pub fn get_update_count(&self) -> u64

Source

pub fn get_frame_count(&self) -> u64

Source§

impl SchedulerState

Source

pub fn new(last_time: f64) -> Self

Trait Implementations§

Source§

impl Clone for SchedulerState

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SchedulerState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SchedulerState

Implements Default for SchedulerState as a freshly created stopped state.

Source§

fn default() -> SchedulerState

Constructs a default SchedulerState value.

§Returns
  • SchedulerState - A default-constructed instance with the documented initial state.
Source§

impl PartialEq for SchedulerState

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SchedulerState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more