知识卡片
Pending须有唤醒路径
返回 Pending 前需要确保当情况可能变化时有人触发当前 Waker。唤醒只是重新调度的提示,新一轮 poll 仍要验证条件。I/O 驱动、消息生产者和定时器可以各自保存唤醒句柄。应保存最新一次 poll 给出的句柄。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 2. Basic Async Rust Context、唤醒与超时 · 查看原书依据
Our program does not complete, and the program hangs. This is because our tasks are still idle, but there is no way to wake them up again to be polled and executed to completion. Futures need the Waker::wake() function so it can be called when the future should be polled again. The process takes the following steps:
参考来源
- 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第02章《Chapter 2. Basic Async Rust》,Context、唤醒与超时(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch02.html#id13)
- 结论依据:去除计数 Future 的唤醒后,任务首次轮询即停滞。
- 原始内容:Our program does not complete, and the program hangs. This is because our tasks are still idle, but there is no way to wake them up again to be polled and executed to completion. Futures need the Waker::wake() function so it can be called when the future should be polled again. The process takes the following steps: