知识卡片

普通读书笔记卡 · 5963.e

消息传递减少共享状态耦合

理解等级:中级

通道将值从发送者交给接收者,使线程通过通信协调,而非都直接修改同一份内存。Rust标准mpsc返回Sender与Receiver,可据此组织拥有关系。消息传递不自动保证无阻塞或业务顺序正确,仍需设计容量、关闭、错误及接收流程。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Chapter 3. Concepts Advice · 查看原书依据

      Sender, Receiver) pair that allows values of a particular type to be communicated between threads. If shared-state concurrency can’t be avoided, then there are some ways to reduce the chances of writing deadlock-prone code: Put data structures that must be kept consistent with each other under a single lock. Keep lock scopes small and obvious; wherever possi

    参考来源

    - 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第3章《Advice》(spine7;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch03.html;u105-ch03-040)。 - 结论依据:原文在“Sender, Receiver”附近的定义、例子或代码支撑本卡核心说明:通道将值从发送者交给接收者,使线程通过通信协调,而非都直接修改同一份内存。边界按已读前提解释;示例未执行。 - 原始内容:Sender, Receiver) pair that allows values of a particular type to be communicated between threads. If shared-state concurrency can’t be avoided, then there are some ways to reduce the chances of writing deadlock-prone code: Put data structures that must be kept consistent with each other under a single lock. Keep lock scopes small and obvious; wherever possi