← 返回刚才阅读的位置

知识卡片

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

复用文件句柄避免重开

理解等级:高级

写同一文件的许多记录时,可先打开文件,以循环、写入器结构或协程持有句柄。实验要固定输入和刷盘策略,单独比较打开策略与协程机制,避免将减少系统调用的收益归给暂停语法。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Chapter 5. Coroutines 跨恢复保留 I/O 资源 · 查看原书依据

      Our updated test will give us a time of roughly 622.6 ms. This is roughly six times faster. Sure, we could have just created the file descriptor and referenced it in the loop to get the same effect, but this demonstrates that there is a benefit to suspending the state of a coroutine and resuming it when needed. We managed to keep our write logic

    参考来源

    - 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第05章《Chapter 5. Coroutines》,跨恢复保留 I/O 资源(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch05.html#id31) - 结论依据:原书比较逐条打开与保留句柄,并指出普通循环也可复用。 - 原始内容:Our updated test will give us a time of roughly 622.6 ms. This is roughly six times faster. Sure, we could have just created the file descriptor and referenced it in the loop to get the same effect, but this demonstrates that there is a benefit to suspending the state of a coroutine and resuming it when needed. We managed to keep our write logic