pub trait AsyncDriver: SchedulerClock {
// Required methods
fn capabilities(&self) -> SchedulerCapabilities;
fn wait_for_event(&self) -> impl Future<Output = ()>;
// Provided method
fn yield_now(&self) -> impl Future<Output = ()> { ... }
}Expand description
异步主循环调度器抽象(面向 Tokio / smol / Std / 自定义测试宿主)。
将 AsyncPlatform 与具体执行器彻底解耦:
- 活跃渲染期间:按
AsyncLoopConfig::frame_interval节流,并在渲染超时时调用Self::yield_now让出调度片; - 画面静止期间(
PlatformControlFlow::Wait):挂起在Self::wait_for_event上,实现 0% CPU 占用。
Required Methods§
Sourcefn capabilities(&self) -> SchedulerCapabilities
fn capabilities(&self) -> SchedulerCapabilities
返回当前调度器的能力元信息。
Sourcefn wait_for_event(&self) -> impl Future<Output = ()>
fn wait_for_event(&self) -> impl Future<Output = ()>
当画面静止(PlatformControlFlow::Wait)时挂起等待外部事件(输入事件、后台异步完成等)唤醒。
实现方应保证黏性(latched)唤醒语义(例如 UiWakeSignal),避免在进入 wait_for_event 前夕触发的唤醒丢失。
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".