4 ms·
Thank you, this is indeed true, though it's important to be aware of implementation differences - poll-based Futures that are "merged" into a single big Task li
by neonsunset 2y ago
Thank you, this is indeed true, though it's important to be aware of implementation differences - poll-based Futures that are "merged" into a single big Task like Rust, or continuation-scheduling granular hot-started Tasks like C#.
e.g. in C#, the following is true:
using var http = new HttpClient() {
BaseAddress = new("https://news.ycombinator.com/")
};
// Runs sequentially
var page1 = await http.GetStringAsync("?p=1");
var page2 = await http.GetStringAsync("?p=2");
// Submitted sequentially, everything after the first yield completes in parallel, IO does not block the caller
var page3 = http.GetStringAsync("?p=3");
var page4 = http.GetStringAsync("?p=4");
// Waits for page3, then page4 to complete, they are effectively parallel
DoSomething(page1, page2, await page3, await page4);
But in Rust, this requires explicit join handle, and if you would like to parallelize/fork the execution flow - you have to schedule a separate task. It requires more effort but in return you get lower async overhead, which is critical for areas Rust is applied to (and host-starting Tasks or Futures would not be easily compatible with borrow checker I presume).