← 返回刚才阅读的位置

知识卡片

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

Future轮询状态

理解等级:中级

调用 async 函数得到惰性的 Future,它可能保存参数以及跨等待点仍活跃的局部状态。执行器通过任务间接调用 poll。Ready 表示完成,随后不得再依赖重复轮询有意义。Pending 要有后续唤醒路径,否则计算可能永远卡在等待中。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Chapter 2. Basic Async Rust Future 的状态与轮询 · 查看原书依据

      To truly understand how a future works, we’ll cover its lifecycle. When a future is created, it is idle. It has yet to be executed. Once the future is executed, it can either yield a value, resolve, or go to sleep because the future is pending (awaiting on a result). When the future is polled again, the poll can return either a Pending or Ready

    参考来源

    - 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第02章《Chapter 2. Basic Async Rust》,Future 的状态与轮询(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch02.html#id11) - 结论依据:计数 Future 展示创建、Pending、再次轮询与 Ready 的过程。 - 原始内容:To truly understand how a future works, we’ll cover its lifecycle. When a future is created, it is idle. It has yet to be executed. Once the future is executed, it can either yield a value, resolve, or go to sleep because the future is pending (awaiting on a result). When the future is polled again, the poll can return either a Pending or Ready