Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Can someone explain how runtimes for async and await work on an assembly level?
Hello,
I am following the book Futures and the Async Syntax - The Rust Programming Language
and have a question on runtimes:
when async
or await
is called then the code will issue a procedure that does not require CPU time. The compiler will need to issue instructions to manage this procedure. What is meant by the state of the async
block? What does it encompass? And how is the result of the procedure returned on an assembly level? Thanks!
Each await point —that is, every place where the code uses the
await
keyword—represents a place where control is handed back to the runtime. To make that work, Rust needs to keep track of the state involved in the async block so that the runtime can kick off some other work and then come back when it’s ready to try advancing the first one again. This is an invisible state machine, as if you’d written an enum like this to save the current state at each await point:
4 posts - 3 participants
🏷️ rust_feed