知识卡片
运行令牌与结果句柄
调度方持有 Runnable,调用方持有 Task,两者关联同一次计算。首次 schedule 将 Runnable 入队,run 消费这次执行机会;Future Pending 后要由相应的唤醒动作产生下一次机会。worker 围住 poll 的 catch_unwind 仅覆盖可展开的 panic,不能消化普通业务错误或恢复被破坏的共享不变量。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 3. Building Our Own Async Queues 任务入口、运行令牌和计时 · 查看原书依据
Runnable is a handle for a runnable task. Every spawned task has a single Runnable handle, which exists only when the task is scheduled for running. The handle has the run function that polls the task’s future once. Then the runnable is dropped. The runnable appears again only when the waker wakes the task in turn, scheduling the task again. Recall from Chapter 2, if
参考来源
- 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第03章《Chapter 3. Building Our Own Async Queues》,任务入口、运行令牌和计时(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch03.html#id17)
- 结论依据:Runnable 执行一次轮询,唤醒触发再次调度,Task 持有等待结果的入口。
- 原始内容:Runnable is a handle for a runnable task. Every spawned task has a single Runnable handle, which exists only when the task is scheduled for running. The handle has the run function that polls the task’s future once. Then the runnable is dropped. The runnable appears again only when the waker wakes the task in turn, scheduling the task again. Recall from Chapter 2, if