Skip to main content

AsyncDriver

Trait AsyncDriver 

Source
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 与具体执行器彻底解耦:

Required Methods§

Source

fn capabilities(&self) -> SchedulerCapabilities

返回当前调度器的能力元信息。

Source

fn wait_for_event(&self) -> impl Future<Output = ()>

当画面静止(PlatformControlFlow::Wait)时挂起等待外部事件(输入事件、后台异步完成等)唤醒。

实现方应保证黏性(latched)唤醒语义(例如 UiWakeSignal),避免在进入 wait_for_event 前夕触发的唤醒丢失。

Provided Methods§

Source

fn yield_now(&self) -> impl Future<Output = ()>

主动向当前异步执行器让出一次调度片。

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§