← 返回刚才阅读的位置

知识卡片

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

单写者维护队列顺序

理解等级:高级

带顺序约束的写入可集中到一个消费者,按 FIFO 的入队顺序写入。如果业务要求按用户操作发生时间排序,应先定义或分配序号,再决定迟到记录或失败时如何处理。单消费者减小同一文件上的锁竞争,也可能成为吞吐瓶颈。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Chapter 2. Basic Async Rust 用唯一写入者定义顺序 · 查看原书依据

      If the order is essential, then keeping to one future and using data collections like queues will slow down the completion of all steps but will ensure that the steps are processed in the order you need them to be. In this case, if we needed to write to the file in order, we could wrap a queue in a Mutex and give one future

    参考来源

    - 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第02章《Chapter 2. Basic Async Rust》,用唯一写入者定义顺序(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch02.html#id436) - 结论依据:原书对无序日志使用一个消费 Future 和队列的方案。 - 原始内容:If the order is essential, then keeping to one future and using data collections like queues will slow down the completion of all steps but will ensure that the steps are processed in the order you need them to be. In this case, if we needed to write to the file in order, we could wrap a queue in a Mutex and give one future