~/talk

Coroutines for Dummies

Talkat C++Now 2026 · 2026-05-04..05-08· [compilers-and-language-design]
links:none on file
slides:none on file

C++20 coroutines make async code readable but hinge on how co_await transforms an expression into an awaitable with await_ready/await_suspend/await_resume; the compiler saves locals into a coroutine frame and gives an opaque coroutine_handle (a glorified callback). Examples include an awaitable adapter around a callback-based load_from_store, a my_sleep that first spawns threads then a scheduler-backed version, both working but revealing that suspend_never vs suspend_always control eager vs lazy behavior and that final_suspend=suspend_always can keep frames (leaks) while promise allocation is implicit.

AI-written summary · about

  1. 0:00Introduction
  2. 1:48What is a coroutine
  3. 5:20C++20 coroutine keywords
  4. 10:54Coroutine handles explained
  5. 13:02First awaitable type
  6. 26:09Return object and promise type
  7. 33:25Basic coroutine demo
  8. 38:19Is this a coroutine?
  9. 40:26Threads and suspension demo
  10. 51:05Final suspend behavior
  11. 55:55Ordering and threads
  12. 1:00:42Suspend always impact
  13. 1:03:27Coroutines vs async
  14. 1:07:19Scheduler and multiple coroutines
  15. 1:15:27Summary
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.