知识卡片

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

Actor独占可变状态

理解等级:中级

Actor 把状态和修改操作收在同一所有者中。发送者通过邮箱提交命令,邮箱满时依据容量策略等待或拒绝。Actor 执行一条消息期间,后续消息要排队,所以长 I/O 会造成队首阻塞。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第08章《Chapter 8. The Actor Model》,有界邮箱与单次应答(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch08.html#id52) - 结论依据:计数器只通过其唯一接收循环修改,没有将可变引用交给调用者。 - 原始内容:The actor listens to incoming messages by using a multiproducer, single-consumer channel (mpsc), updates the state, and then prints it out. We can test our actor as follows: