知识卡片

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

停车通知防止漏唤醒

理解等级:高级

空闲 worker 要结合队列谓词与唤醒协议决定休眠。如果生产者在 worker 检查队列和声明要睡之间发布,会造成漏唤醒。可在声明休眠后重查工作,或使用有停车许可的正确通知策略,并在每次醒来时重查条件。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第10章《Chapter 10. Building an Async Server with No Dependencies》,轮询分流与工作线程停车(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch10.html#id68) - 结论依据:原书用工作线程休眠标记及 unpark 组织连接派发,显示工作就绪与休眠状态的交界。 - 原始内容:Once we receive the TCP request, we send the TCP stream to a thread, check whether the thread is parked, and unpark the thread if needed. Next, we move the index over to the next thread so we can distribute the requests evenly across all our threads.