We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Deciphering C++ Coroutines - A Diagrammatic Coroutine Cheat Sheet - Andreas Weis - CppCon 2022
Discover the intricacies of C++ coroutines with this comprehensive cheat sheet, covering topics like `await`, suspend points, promises, and customization options for advanced developers.
- 
C++ coroutines consist of the awaitkeyword and thereturnstatement.
- 
Coroutines have three points for suspension: await_suspend,initial_suspend, andfinal_suspend.
- When a coroutine is created, the return type becomes the coroutine’s result type.
- 
When await_suspendis called, control flow returns to the caller, allowing them to store a handle to the coroutine.
- 
When the promiseis passed togetReturnObject, theawait_suspendfunction is called.
- Coroutines do not directly access their suspend points, they rely on their promise for suspension and cancellation.
- Promises hold on to the result type, suspension points and destruction points of coroutines.
- Initial suspend puts the coroutine to sleep.
- Final suspend gets called when a coroutine returns and checks if there’s any unhandled exception.
- Cancellation points determine when and if a coroutine’s execution will resume.
- Co_yield acts like syntactic sugar, allows users to define what’s stored in the promise.
- Coroutine Traits can be customized.
- Initial Suspend and Final Suspend permit controlling what happens when a coroutine enters and leaves the suspension points.