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.
impl SchedulerState
Implements time retrieval and tick execution for SchedulerState.
Sourcepub fn current_time() -> f64
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, or0.0when unavailable.
Sourcepub fn tick(
&mut self,
config: &SchedulerConfig,
handler: &TickHandlerRc,
tasks: Option<&TaskRegistryRc>,
input_cell: Option<&InputStateCell>,
)
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, orNonewhen no tasks are registered.Option<&InputStateCell>- The shared input state to close out, orNonewhen no input listeners are registered.
Source§impl SchedulerState
impl SchedulerState
pub fn get_accumulator(&self) -> f64
pub fn get_last_time(&self) -> f64
pub fn get_running(&self) -> bool
pub fn get_raf_id(&self) -> Option<i32>
pub fn try_get_raf_id(&self) -> Option<i32>
pub fn get_update_count(&self) -> u64
pub fn get_frame_count(&self) -> u64
Trait Implementations§
Source§impl Clone for SchedulerState
impl Clone for SchedulerState
Source§impl Debug for SchedulerState
impl Debug for SchedulerState
Source§impl Default for SchedulerState
Implements Default for SchedulerState as a freshly created stopped state.
impl Default for SchedulerState
Implements Default for SchedulerState as a freshly created stopped state.
Source§fn default() -> SchedulerState
fn default() -> SchedulerState
Constructs a default SchedulerState value.
§Returns
SchedulerState- A default-constructed instance with the documented initial state.