Implementing coroutines using C++17
summary
An actual C++17 coroutine implementation appears, about 200 lines of code with accompanying test cases, and it literally smashes the return address on MSVC x64 using a tiny assembly shim to implement resume. Pause and resume work by storing and restoring the return address via a noinline helper and builtin return address, with an extra asm clobber to force reload of registers. Frame storage uses recursive struct inheritance to compute sizes, macros to declare frames, and explicit cleanup functions for proper destruction — and it runs.
AI-written summary · about
related talks
04mLightning Talk: Implementing Coroutines Using C++17
58mAn Introduction to C++ Coroutines
01h 03mDeciphering C++ Coroutines - A Diagrammatic Coroutine Cheat Sheet
01h 00mUsing Coroutines to Implement C++ Exceptions for Freestanding Environments
01h 05mCoroutines: C++ vs Rust
01h 02mC++20’s Coroutines for Beginners
01h 05mWhy use coroutines for asynchronous applications
55mC++20 coroutines as an API principle
