知识卡片

普通读书笔记卡 · 303.a.2.d · 生成模型:GPT-6

分离异步与阻塞线程

理解等级:高级

工作线程用来快速轮询,长时间阻塞的工作应交给适当的阻塞池。阻塞池线程数上限不限制所有排队提交,仍需视场景做准入控制。thread_keep_alive 管理空闲阻塞线程的寿命,运行中的任务应通过单独的取消协议控制。参见 Tokio 1.48 Builder。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Chapter 7. Customizing Tokio 运行时参数管理不同资源 · 查看原书依据

      The number of threads that can be allocated to blocking tasks. A blocking task does not allow switching because it has no await or requires long periods of CPU computation between await statements. Therefore, the thread is blocked for a fair amount of time processing the task. CPU-intensive tasks or synchronous tasks are usually referred to as blocking tasks. If we block all our threads,

    参考来源

    - 位置:《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#id48) - 结论依据:Builder 示例分别设置 worker_threads 和 max_blocking_threads。 - 原始内容:The number of threads that can be allocated to blocking tasks. A blocking task does not allow switching because it has no await or requires long periods of CPU computation between await statements. Therefore, the thread is blocked for a fair amount of time processing the task. CPU-intensive tasks or synchronous tasks are usually referred to as blocking tasks. If we block all our threads,