-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
建议:
1、从源码来看,当塞入 cpu 密集型任务时,会一直强行占着 tokio 下的执行线程,虽然是异步的,这时彻底回退到 Thread pool(针对这种需要 Thread pool 场景 tokio 建议是使用 spawn_blocking 方法,或者使用 rayon crate 或者 tokio-rayon crate),实际上仅仅适用于偏 io 的场景,所以文档说明上叫 task pool 或者 worker pool 更好一点
2、Task 这个 struct 可以不暴露出来,直接在 submit 方法内去创建
3、Handler 已经实现了 Futue, await_result 感觉是多余的
4、rust 中的惯用法,ThreadPool 直接实现 default trait 方法,而不是单独定义一个 default 方法
Metadata
Metadata
Assignees
Labels
No labels