An Introduction to C++ Coroutines
summary
Proposal shows concrete semantics and a working VC++ prototype: compiler creates a heap-allocated coroutine frame via operator new, uses a promise type and coroutine_handle to resume, and implements await by calling await_ready / await_suspend / await_resume. Examples convert a synchronous TCP reader to asynchronous, adapt std::future via coroutine_traits and nonmember awaitables, and build a generator using suspend_always/suspend_never. Implementation ships in a Visual C++ update but wording and keywords remain evolving.
AI-written summary · about
chapters (17)
- 0:00Start
- 8:49What is a Coroutine?
- 10:19What makes a function a coroutine?
- 12:12What does co await actually do?
- 14:14The simplest awaitable: suspend always
- 14:52Another simple awaitable: suspend never
- 15:26So that's the first half...
- 15:43What happens when you invoke a function?
- 16:08What happens when you invoke a coroutine?
- 25:49Returning from a Coroutine
- 26:24What's in a Promise?
- 29:20Coroutine Lifetime
- 32:44Let's look at future...
- 33:57coroutine_traits
- 43:43Subroutines and Coroutines
- 45:00Coroutine Control Flow
- 45:36Design Principles
related talks
01h 02mC++20’s Coroutines for Beginners
01h 03mDeciphering C++ Coroutines - A Diagrammatic Coroutine Cheat Sheet
01h 05mCoroutines: C++ vs Rust
55mC++20 coroutines as an API principle
06mImplementing coroutines using C++17
01h 05mWhy use coroutines for asynchronous applications
47mC++ coroutines and Qt
57m[filtered] Asynchronous C++ Programming
