知识卡片
异构任务统一执行接口
调度只需要知道能否继续推进一个任务,无需了解业务值类型。队列保存同一 Future 接口,调用者持有对应的 Receiver 取得结果。装箱会引入分配与间接调用,但解除队列与每种返回类型的绑定。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 10. Building an Async Server with No Dependencies 类型擦除与结果回传 · 查看原书依据
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
参考来源
- 位置:《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