知识卡片
验证等待不会提前推进
测试状态机的等待分支要观察内部或外部进度未消耗,并验证解除条件后恰好推进一次。只检查最终累加结果容易漏掉失败时扣计数或重复推进。真正运行时测试再补充句柄返回、唤醒与完成状态。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 5. Coroutines 同步逐步检查和异步集成检查 · 查看原书依据
We execute the loop to prove that the threshold is also not being altered when the coroutine fails to get the lock. If the threshold had been altered, after two iterations the coroutine would have returned a complete, and the next call to the coroutine would have resulted in an error. While the test would have picked this up without the loop, having the loop
参考来源
- 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第05章《Chapter 5. Coroutines》,同步逐步检查和异步集成检查(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch05.html#id38)
- 结论依据:书中持锁时重复恢复协程,再解锁核对每一步,证明失败路径未消耗剩余工作。
- 原始内容:We execute the loop to prove that the threshold is also not being altered when the coroutine fails to get the lock. If the threshold had been altered, after two iterations the coroutine would have returned a complete, and the next call to the coroutine would have resulted in an error. While the test would have picked this up without the loop, having the loop