← 返回起始笔记位置

知识卡片

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

条件变量通知状态

理解等级:中级

Arc 让线程共享数据的所有权,Mutex 保护条件和关联数据。Condvar 等待会释放互斥锁并停车,返回时再次取得锁。条件可能尚未成立,唤醒也可能没有对应更新,等待者应在同一锁保护下循环检查谓词。Relaxed 原子量适合独立标记,关联数据仍要遵守同步协议。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Chapter 1. Introduction to Async 线程并行与共享状态 · 查看原书依据

      Here we can see that we wait on the Condvar notification. At the point of waiting, the thread is said to be parked. This means that the thread is blocked and not executing. Once the notification comes in from the Condvar, the thread accesses the variable in the Mutex after being woken by the Condvar. We then print out the variable, and the thread goes

    参考来源

    - 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第01章《Chapter 1. Introduction to Async》,线程并行与共享状态(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch01.html#id6) - 结论依据:示例把共享布尔值放在 Mutex 中,等待者在收到 Condvar 通知后重新访问它。 - 原始内容:Here we can see that we wait on the Condvar notification. At the point of waiting, the thread is said to be parked. This means that the thread is blocked and not executing. Once the notification comes in from the Condvar, the thread accesses the variable in the Mutex after being woken by the Condvar. We then print out the variable, and the thread goes