知识卡片
线程亲和限制窃取
把任务固定到线程可复用本地缓存、访问线程绑定资源并降低锁竞争。其他空闲线程不能接管积压,阻塞会更明显。需要全局聚合时显式向各线程发送查询并定义合并时点。线程亲和描述谁来轮询,Pin 描述值可否移动,两者解决不同问题。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
- · 本地池与线程亲和
原书出处 · 1 处
- Chapter 7. Customizing Tokio 本地池与线程亲和 · 查看原书依据
When using local pools, we tie the spawned async task to the specific pool. This means we can use structs that do not have the Send trait implemented because we are ensuring that the task stays on a specific thread. However, because we are ensuring that the async task runs on a particular thread, we will not be able to exploit task stealing; we will
参考来源
- 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第07章《Chapter 7. Customizing Tokio》,本地池与线程亲和(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch07.html#id49)
- 结论依据:本地池限定任务留在原线程,可使用非 Send 资源,但放弃任务迁移。
- 原始内容:When using local pools, we tie the spawned async task to the specific pool. This means we can use structs that do not have the Send trait implemented because we are ensuring that the task stays on a specific thread. However, because we are ensuring that the async task runs on a particular thread, we will not be able to exploit task stealing; we will