pub struct RuntimeHandle { /* private fields */ }Expand description
A cheap handle to a Runtime. It does not keep the runtime alive, and its calls do nothing
once the runtime is dropped.
Implementations§
Source§impl RuntimeHandle
impl RuntimeHandle
Sourcepub fn state_arena_stats(&self) -> (usize, usize)
pub fn state_arena_stats(&self) -> (usize, usize)
Returns the number of state cells and, of those, the number free for reuse.
Sourcepub fn state_arena_debug_stats(&self) -> StateArenaDebugStats
pub fn state_arena_debug_stats(&self) -> StateArenaDebugStats
Returns the sizes of the runtime’s state arena, for leak and memory checks.
Sourcepub fn debug_stats(&self) -> RuntimeDebugStats
pub fn debug_stats(&self) -> RuntimeDebugStats
Returns the sizes of the runtime’s queues and tables, for leak and memory checks.
Sourcepub fn live_ui_task_labels(&self) -> Vec<(u64, String)>
pub fn live_ui_task_labels(&self) -> Vec<(u64, String)>
Returns the id and label of every spawned UI task that has not finished.
Sourcepub fn enqueue_ui_task(&self, task: Box<dyn FnOnce() + 'static>)
pub fn enqueue_ui_task(&self, task: Box<dyn FnOnce() + 'static>)
Schedules work that must run on the runtime thread.
The closure executes on the UI thread immediately when the runtime
drains its local queue, so it may capture Rc/RefCell values. Calling
this from any other thread is a logic error and will panic in debug
builds via the inner assertion.
Sourcepub fn spawn_ui<F>(&self, fut: F) -> Option<TaskHandle>
pub fn spawn_ui<F>(&self, fut: F) -> Option<TaskHandle>
Spawns fut on the UI thread, where drain_ui polls it whenever it is woken. Returns
None if the runtime is gone.
Sourcepub fn cancel_task(&self, id: u64)
pub fn cancel_task(&self, id: u64)
Cancels the spawned UI task id and drops its future.
Sourcepub fn post_ui(&self, task: impl FnOnce() + Send + 'static)
pub fn post_ui(&self, task: impl FnOnce() + Send + 'static)
Enqueues work from any thread to run on the UI thread.
The closure must be Send because it may cross threads before executing
on the runtime thread. Use this when posting from background work.
Sourcepub fn register_ui_cont<T: 'static>(
&self,
f: impl FnOnce(T) + 'static,
) -> Option<u64>
pub fn register_ui_cont<T: 'static>( &self, f: impl FnOnce(T) + 'static, ) -> Option<u64>
Registers f to run once on the UI thread when UiDispatcher::post_invoke sends a T for
the returned id. Returns None if the runtime is gone.
Sourcepub fn cancel_ui_cont(&self, id: u64)
pub fn cancel_ui_cont(&self, id: u64)
Removes the continuation id without running it.
Sourcepub fn drain_ui(&self)
pub fn drain_ui(&self)
Runs the work posted to the UI thread, including woken tasks, until none is left.
Sourcepub fn has_pending_ui(&self) -> bool
pub fn has_pending_ui(&self) -> bool
Returns true if posted UI work has not run yet.
Sourcepub fn register_frame_callback(
&self,
callback: impl FnOnce(u64) + 'static,
) -> Option<u64>
pub fn register_frame_callback( &self, callback: impl FnOnce(u64) + 'static, ) -> Option<u64>
Registers callback to run once on the next frame with the frame time in nanoseconds.
Returns None if the runtime is gone.
Sourcepub fn register_perpetual_frame_callback(
&self,
callback: impl FnOnce(u64) + 'static,
) -> Option<u64>
pub fn register_perpetual_frame_callback( &self, callback: impl FnOnce(u64) + 'static, ) -> Option<u64>
Registers callback to run once on the next frame, for a long-lived loop that registers
again after every frame. It does not count in has_transient_frame_callbacks.
Sourcepub fn cancel_frame_callback(&self, id: u64)
pub fn cancel_frame_callback(&self, id: u64)
Cancels the frame callback id if it has not run.
Sourcepub fn drain_frame_callbacks(&self, frame_time_nanos: u64)
pub fn drain_frame_callbacks(&self, frame_time_nanos: u64)
Delivers callbacks registered before this display frame. Timestamps use one monotonic nanosecond epoch; duplicate or older timestamps are ignored. A callback registered during delivery waits for a newer frame timestamp.
Sourcepub fn last_frame_time_nanos(&self) -> Option<u64>
pub fn last_frame_time_nanos(&self) -> Option<u64>
Animation-clock time of the most recent frame-callback drain (see
Runtime::last_frame_time_nanos).
Sourcepub fn frame_clock(&self) -> FrameClock
pub fn frame_clock(&self) -> FrameClock
Returns a clock for the frames of this runtime.
Sourcepub fn set_needs_frame(&self, value: bool)
pub fn set_needs_frame(&self, value: bool)
Sets or clears the request for a frame.
Sourcepub fn has_updates(&self) -> bool
pub fn has_updates(&self) -> bool
Returns true if node updates are queued or any recompose scope is invalid.
Sourcepub fn forget_movable(&self, id: Key)
pub fn forget_movable(&self, id: Key)
Releases the retained state of the movable content with identity
id at the composition’s next opportunity. See
crate::forget_movable.
Sourcepub fn has_invalid_scopes(&self) -> bool
pub fn has_invalid_scopes(&self) -> bool
Returns true if a recompose scope has been invalidated and not yet recomposed.
Sourcepub fn has_frame_callbacks(&self) -> bool
pub fn has_frame_callbacks(&self) -> bool
Returns true if any frame callback, transient or perpetual, is waiting.
Sourcepub fn has_transient_frame_callbacks(&self) -> bool
pub fn has_transient_frame_callbacks(&self) -> bool
Returns true if a callback from register_frame_callback is waiting. Perpetual callbacks
do not count.
Sourcepub fn assert_ui_thread(&self)
pub fn assert_ui_thread(&self)
Panics in debug builds when called off the runtime’s UI thread.
Sourcepub fn dispatcher(&self) -> UiDispatcher
pub fn dispatcher(&self) -> UiDispatcher
Returns a dispatcher that posts work to the UI thread from any thread.