Overview of Coroutines
Explore how C++20 coroutines allow functions to suspend and resume execution while preserving state. Understand the use of co_await and co_yield keywords to write asynchronous, non-blocking code and create lazy generators. This lesson helps you grasp coroutine behavior, enabling you to implement efficient event-driven workflows and infinite data streams in C++.
We'll cover the following...
Coroutines are functions that can suspend and resume their execution while keeping their state. The evolution of functions in C++ goes one step further.
⚠️ The challenge of understanding coroutines
It was quite a challenge for me to understand coroutines. I strongly suggest that you should not read the sections in the chapter in sequence. Skip in your first iteration the sections “The Framework”, and “The Workflow”. Furthermore, read the case studies “Variations of Futures”, “Modification and Generalization of a Generator”, and “Various Job Workflows”. Reading, ...