Final thoughts on coroutines and their implementations in C++
The examples earlier were practical, although not so simple. They were useful in understanding the sequence that a coroutine’s execution might take. It is good to visualize the state graph of coroutines, although we still believe it would be confusing for inexperienced developers.
As presented earlier, Figure 10.2, Figure 10.3, and Figure 10.4 pretty much cover what we’ve already explained through the code examples. It is useful to understand how much additional logic is generated around the coroutine and its members. Most of it happens in the background, and the system programmer only arranges the scheduling. In this chapter’s examples, we did this through the promise
object and awaitables. The fact that the aforementioned figures partially represent a coroutine’s execution as a finite state machine should hint to you that this is another application where coroutines are useful. They transform...