pub struct SchedulerHandle { /* private fields */ }Expand description
A handle to a running scheduler, allowing the caller to stop it later.
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.
Source§impl SchedulerHandle
impl SchedulerHandle
pub fn get_state(&self) -> &Rc<EngineCell<SchedulerState>>
pub fn get_closure_cell(&self) -> &RafClosureCell
Source§impl SchedulerHandle
impl SchedulerHandle
pub fn new( state: Rc<EngineCell<SchedulerState>>, closure_cell: RafClosureCell, ) -> Self
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SchedulerHandle
impl !Send for SchedulerHandle
impl !Sync for SchedulerHandle
impl !UnwindSafe for SchedulerHandle
impl Freeze for SchedulerHandle
impl Unpin for SchedulerHandle
impl UnsafeUnpin for SchedulerHandle
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