Coroutines: More Details
Explore the advanced details of C++20 coroutines, focusing on their design as asymmetric, first-class, stackless constructs. Understand how coroutines support cooperative multitasking in applications such as simulations, servers, and games by using co_return, co_yield, and co_await. This lesson helps you grasp coroutine mechanics for scalable and efficient asynchronous programming.
We'll cover the following...
Typical Use-Cases
Coroutines are the natural way to write event-driven applications; e.g. simulations, games, servers, user interfaces, or even algorithms. Coroutines are typically used for cooperative multitasking. The key to cooperative multitasking is that each task takes as much time as it needs. This is in contrast to pre-emptive multitasking, for which we have a scheduler that decides how long each task gets the CPU.
That being said, there are different kinds of coroutines.
Underlying Concepts
Coroutines in C++20 are asymmetric, first-class, and stackless.
The workflow of an asymmetric coroutine goes back ...