Coroutines and async/await
Now that you’ve gotten a brief introduction to Rust’s async model, it’s time to take a look at how this fits in the context of everything else we’ve covered in this book so far.
Rust’s futures are an example of an asynchronous model based on stackless coroutines, and in this chapter, we’ll take a look at what that really means and how it differs from stackful coroutines (fibers/green threads).
We’ll center everything around an example based on a simplified model of futures and async/await
and see how we can use that to create suspendable and resumable tasks just like we did when creating our own fibers.
The good news is that this is a lot easier than implementing our own fibers/green threads since we can stay in Rust, which is safer. The flip side is that it’s a little more abstract and ties into programming language theory as much as it does computer science.
In this chapter, we’ll...