The Framework
Learn how the C++20 coroutine framework operates through its key components: promise objects managing states and results, coroutine handles controlling execution, and coroutine frames handling local variables. Understand how these parts interact to enable tailored, resumable asynchronous functions for event-driven programming.
We'll cover the following...
The framework for implementing coroutines consists of more than functions, some of which you must implement and some of which you may overwrite. Therefore, you can tailor the coroutine to your needs.
A coroutine is associated with three parts: the promise object, the coroutine handle, and the coroutine frame. The client gets the coroutine handle to interact with the promise object, which keeps its state in the coroutine frame.
Promise object
The promise object is manipulated from inside the coroutine. It delivers its result or exception via the promise object.
The promise object must support the following interface.
| Member function | Description |
|---|