Skip to main content

run_async_event_loop

Function run_async_event_loop 

Source
pub async fn run_async_event_loop<P, D>(
    platform: &mut P,
    engine: &mut VeloxEngine,
    driver: &D,
    config: AsyncLoopConfig,
) -> AsyncLoopReport
Expand description

跨调度器、全平台通用的异步主循环驱动函数。

统一协调 AsyncPlatform、VeloxEngine 与可插拔 AsyncDriver:

  1. 使用 SchedulerClock::now_ms 自动计算真实增量 dt_ms(钳位至 1..=100 ms);
  2. 异步调用 platform.step_platform_async(engine, dt_ms).await;
  3. 返回 Poll 时按剩余帧预算 driver.sleep(...).await 或 driver.yield_now().await;
  4. 返回 Wait 且无新增脏状态时,挂起在 driver.wait_for_event().await 进入 0% CPU 休眠;
  5. 返回 Exit 或达到 config.max_steps 时干净退出并返回 AsyncLoopReport。