知识卡片
异步让出等待时间
网络服务中的处理逻辑经常等待 I/O,异步任务可在等待期间暂停,让执行线程处理其他就绪任务。Actix 示例用异步入口和 .await 驱动服务,避免按连接占用一个线程。密集计算仍需考虑可用处理器和工作切分。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- A Tour of Rust 用类型连接表单、处理器和响应 · 查看原书依据
They’re a way to deal with tasks that don’t need the CPU all the time—perhaps because, as in our case, they will spend
参考来源
- 位置:《Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)》第01章《A Tour of Rust》|用类型连接表单、处理器和响应,来源项目 `book-source`,`extracted/Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)/_epub-src/OEBPS/ch01.xhtml#serving-pages-to-the-web`
- 结论依据:原文解释网络等待与一个核心上并行调度多个异步任务的关系。
- 原始内容:They’re a way to deal with tasks that don’t need the CPU all the time—perhaps because, as in our case, they will spend