pub struct SchedulerHandle {
pub state: Rc<EngineCell<SchedulerState>>,
pub closure_cell: RafClosureCell,
}Expand description
A handle to a running scheduler, allowing the caller to stop it later.
Fields§
§state: Rc<EngineCell<SchedulerState>>The shared scheduler state, held behind EngineCell (an
UnsafeCell-backed Sync newtype) so multiple closure
captures can mutate it without RefCell’s runtime borrow
check. Mirrors core::reactive::schedule shape.
get_state is public because tests/api_visibility/fn.rs reads this field from
outside this crate. get_mut / set stay crate-internal.
closure_cell: RafClosureCellThe shared closure cell keeping the RAF callback alive. Held
behind MaybeEngineCell because the cell is empty both
before spawn runs and after cleanup tears the closure down.
get_closure_cell is public because tests/api_visibility/fn.rs reads this field from
outside this crate. get_mut / set stay crate-internal.
Implementations§
Source§impl SchedulerHandle
Implements lifecycle management for SchedulerHandle.
impl SchedulerHandle
Implements lifecycle management for SchedulerHandle.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Returns whether the scheduler is currently running.
§Returns
bool- True if the scheduler is running.
Sourcepub fn update_count(&self) -> u64
pub fn update_count(&self) -> u64
Sourcepub fn frame_count(&self) -> u64
pub fn frame_count(&self) -> u64
Sourcepub fn register_task<T>(registry: &TaskRegistryRc, task: T) -> TaskHandlewhere
T: Updatable + 'static,
pub fn register_task<T>(registry: &TaskRegistryRc, task: T) -> TaskHandlewhere
T: Updatable + 'static,
Registers a task to be advanced on every fixed step.
The task is driven by SchedulerState::tick immediately after the
handler’s on_update callback, using the same
SchedulerConfig::get_fixed_timestep delta.
§Arguments
&TaskRegistryRc- The registry to add the task to.T- The updater to register. Must implementUpdatable.
§Returns
TaskHandle- A handle used to unregister the task.
Sourcepub fn start(
config: SchedulerConfig,
handler: TickHandlerRc,
tasks: Option<&TaskRegistryRc>,
input_cell: Option<&InputStateCell>,
) -> SchedulerHandle
pub fn start( config: SchedulerConfig, handler: TickHandlerRc, tasks: Option<&TaskRegistryRc>, input_cell: Option<&InputStateCell>, ) -> SchedulerHandle
Starts the scheduler with the given configuration and handler.
Creates a requestAnimationFrame-driven loop that calls tick
on each animation frame. The returned SchedulerHandle can be used to stop the scheduler.
When no global window exists (non-browser context), the scheduler is not started and an already-stopped handle is returned instead.
§Arguments
SchedulerConfig- The scheduler configuration.TickHandlerRc- The handler receiving update and render callbacks.Option<&TaskRegistryRc>- The task registry advanced on every fixed step, orNonewhen no tasks are registered.Option<&InputStateCell>- The shared input state whose per-frame edge state is cleared at the end of every frame, orNonewhen input listeners are not registered.
§Returns
SchedulerHandle- A handle to control the running scheduler.