← 返回刚才阅读的位置

知识卡片

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

异构任务统一执行接口

理解等级:中级

调度只需要知道能否继续推进一个任务,无需了解业务值类型。队列保存同一 Future 接口,调用者持有对应的 Receiver 取得结果。装箱会引入分配与间接调用,但解除队列与每种返回类型的绑定。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第10章《Chapter 10. Building an Async Server with No Dependencies》,类型擦除与结果回传(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch10.html#id65) - 结论依据:原书将有不同输出的 Future 包装并从结果通道回传 T。 - 原始内容:However, what happens with generics is that the compiler will look at all the instances of Task<T> and generate structs for every variance of T. Also, our executor will need the T generic argument to process Task<T>. This will result in multiple executors for each variance of T, which would result in a mess. Instead, we wrap our future in an async block, get the