知识卡片
同队列多消费者
多消费者队列把待运行工作分配给空闲线程,并避免同一排队项被所有消费者重复处理。调度仍会受核数、队列竞争和长任务影响。应结合负载控制工作池资源,对延迟和关键线路有隔离要求时可拆池。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 3. Building Our Own Async Queues 共享队列与工作线程数 · 查看原书依据
If we send tasks through the channel, the traffic will generally be distributed across both threads. If one thread is blocked with a CPU-intensive task, the other thread will continue to work through tasks. Recall that Chapter 1 proved that CPU-intensive tasks can be run in parallel by using threads with our Fibonacci number example. We can have a more ergonomic approach to building a
参考来源
- 位置:《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#id79)
- 结论依据:两个接收者从同一个队列取工作,原书随后展示以循环创建线程池。
- 原始内容:If we send tasks through the channel, the traffic will generally be distributed across both threads. If one thread is blocked with a CPU-intensive task, the other thread will continue to work through tasks. Recall that Chapter 1 proved that CPU-intensive tasks can be run in parallel by using threads with our Fibonacci number example. We can have a more ergonomic approach to building a