Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
-
Minimizing usage of async Rust. Refactor coded as much as possible to be in sync functions, and have async just be little "router wrappers" for waiting on stuff and feeding it to sync functions. See good discussion at Avoid Async Rust at all costs” - comments from experts? .
-
Combining asynchronous code with synchronous code that can cause blocking is never a wise choice. When calling asynchronous code from a synchronous context, use
futures::executor::block_onand spawn the async code to a dedicated runtime, because the former will block the current thread. On the other hand, if you have to call blocking synchronous code from an asynchronous context, it is recommended to usetokio::task::spawn_blockingto execute the code on a dedicated executor that handles blocking operations.
Issues in Async Rust
Tutorials
Basics of Rust Concurrency (Atomics and Locks Chapter 1)