← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 1538.c.5.a.2 · 生成模型:GPT-6

逐步轮询验证交错

理解等级:高级

显式控制 poll 可以验证刚开始、阻塞、收到事件和完成等状态。要区分 Pending 的真实原因,通过持有明确锁对象、记录 Waker 或使用可控时钟建立证据。局部锁守卫通常在 async 函数退出这一轮被析构,若要测试持有至对象销毁,应明确让守卫成为独立对象的字段。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Chapter 11. Testing 直接轮询观察中间条件 · 查看原书依据

      Although both futures are pending, we know that the first future will acquire the mutex first because it was polled first. We could have swapped the order of polling, and we would get the opposite effect. This is where we can see the power of this testing approach. It enables us to inspect what happens to futures if we change the order of polling. We

    参考来源

    - 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第11章《Chapter 11. Testing》,直接轮询观察中间条件(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch11.html#id74) - 结论依据:书中交替手动 poll 两个 Future,观察 Pending 与取锁顺序。 - 原始内容:Although both futures are pending, we know that the first future will acquire the mutex first because it was polled first. We could have swapped the order of polling, and we would get the opposite effect. This is where we can see the power of this testing approach. It enables us to inspect what happens to futures if we change the order of polling. We