Rust 程序设计语言 简体中文版 1.85.0
文件名:src/main.rs 398/562Rust 程序设计语言 简体中文版 fn slow(name: &str, ms: u64) { thread::sleep(Duration::from_millis(ms)); println!("'{name}' ran for {ms}ms"); } 在示例 17-22 中,我们使用 slow 在几个 future 中模拟这类 CPU 密集型工作。首先,每个 如果运行代码,你会看到这些输出: 'a' started. 'a' ran for 30ms 'a' ran for 10ms 'a' ran for 20ms 'b' started. 'b' ran for 75ms 'b' ran for 10ms 'b' ran for 15ms 'b' ran for 350ms 'a' finished. 与上一个示例一样,race 仍然在 a 完成后就立刻结束了。两个 程序设计语言 简体中文版 let one_ms = Duration::from_millis(1); let a = async { println!("'a' started."); slow("a", 30); trpl::sleep(one_ms).await; slow("a"0 码力 | 562 页 | 3.23 MB | 8 天前3Tornado 6.5 Documentation
be delayed and/or combined to minimize the number of packets sent. This can sometimes cause 200-500ms delays due to the interaction between Nagle’s algorithm and TCP delayed ACKs. To reduce this delay (for more information, see http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCONNECTTIMEOUT MS and comments in curl_httpclient.py). To select curl_httpclient, call AsyncHTTPClient.configure at0 码力 | 437 页 | 405.14 KB | 2 月前3Tornado 6.5 Documentation
be delayed and/or combined to minimize the number of packets sent. This can sometimes cause 200-500ms delays due to the interaction between Nagle’s algorithm and TCP delayed ACKs. To reduce this delay0 码力 | 272 页 | 1.12 MB | 2 月前3
共 3 条
- 1