← 返回刚才阅读的位置

知识卡片

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

同步入口分离提交与等待

理解等级:中级

迁移同步代码时,可以先提供提交和取结果两个入口,将 async 类型和运行时隔离在模块内。结果是否只消费一次、等待能否超时、未领取的句柄何时回收都要写明。异步工作线程内应选异步等待接口,避免嵌套阻塞运行时。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Chapter 9. Design Patterns 同步提交与阻塞取结果 · 查看原书依据

      As Figure 9-1 lays out, we send an async task to the runtime, put the handle in a map for those async tasks, and return a key that corresponds to the handle in the map. The developer using the module calls a normal blocking function and receives a unique ID back. The task is being progressed in the async runtime, and the developer can write

    参考来源

    - 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第09章《Chapter 9. Design Patterns》,同步提交与阻塞取结果(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch09.html#buildIsolatedModule) - 结论依据:书中用 ID 代表可延后等待的句柄,在同步接口背后独立推进异步工作。 - 原始内容:As Figure 9-1 lays out, we send an async task to the runtime, put the handle in a map for those async tasks, and return a key that corresponds to the handle in the map. The developer using the module calls a normal blocking function and receives a unique ID back. The task is being progressed in the async runtime, and the developer can write