consolidating my understanding of `async`/`await` in C# and Rust
Please confirm or correct the following:
- A
Futurerepresents a workload that has yet to be done - C# doesn't use
Futures (at least not remotely as ubiquitous as Rust) - "Spawning" (e.g. via
tokio::spawn(my_future)) begins (and ONLY begins) the execution of such a workload, and returns aTaskthat represents the execution - Calling an async C# function which returns a
Taskis analog to immediately spawning the future returned by an async Rust function - A
Taskcallingawaiton anotherTaskis analog (but NOT equivalent) to aThreadcalling.Join()on anotherThread(except that the join handle of a C#Threadcannot convey a result, so the analogy fails forTask<T>) .ConfigureAwait(false)in C# is analog to using a multi-threaded runtime in Rust, and indicates that the workload may be executed not only concurrently, but also in parallel. This distinction is mostly relevant for context dependent workloads (e.g. some platforms restrict UI manipulation to the main thread), but also affects whether or not data races can occur- Exceptions thrown in async functions are automatically catched, stored in the returend
Taskobject, and rethrown onawait - calling an
async voidmethod is like calling anasync Taskand discarding the returnedTaskobject, except that exceptions aren't catched, and can instead kill the entire thread