← 返回刚才阅读的位置

知识卡片

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

异步写入的三种承诺

理解等级:中级

write 成功说明底层本次接收了若干字节。flush 表示缓冲按接口约定向下层送出。shutdown 是结束写方向的协议动作。跨多次轮询要保存已写偏移,避免 Pending、短写或取消时重发同一段。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第04章《Chapter 4. Integrating Networking into Our Own Async Runtime》,写入、送出缓冲与半关闭(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch04.html#id27) - 结论依据:AsyncWrite 为写入、flush、shutdown 分别提供可轮询的方法。 - 原始内容:The poll_write function should not be a surprise, but note that we also have poll_flush and poll_shutdown functions. All the functions return a variant of the Poll enum and accept the context. Therefore, we can deduce that all functions are able to put the task to sleep to be woken again and to check whether the future is ready for shutting down, flushing, and writing