知识卡片
外部就绪驱动轮询
将“检查结果”和“登记 Waker”置于同一同步协议,避免生产者在两步之间发布结果而漏掉通知。生产者先到时直接存结果,后到时更新结果并通知已有等待者。让任务在无进展时安静等待,可避免反复自唤醒造成的空转。参见 [[Pending须有唤醒路径]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 2. Basic Async Rust 把就绪信号交给外部生产者 · 查看原书依据
Here we can see that we print every time we poll the future to keep track of how many times we poll our future. We then access the state and see if there is any data. If there is no data, we pass the waker into the state so we can wake the future from outside of the future. If there is data in the
参考来源
- 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第02章《Chapter 2. Basic Async Rust》,把就绪信号交给外部生产者(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch02.html#id14)
- 结论依据:共享状态封装结果与唤醒句柄,首次无数据时留存 Waker,随后由触发任务发布结果。
- 原始内容:Here we can see that we print every time we poll the future to keep track of how many times we poll our future. We then access the state and see if there is any data. If there is no data, we pass the waker into the state so we can wake the future from outside of the future. If there is data in the