~/talk

C++ Coroutines from scratch

Talkat NDC TechTown 2023 · 2023-09-18..09-21· [concurrency]
slides:none on file

Starts from plain functions and implements working coroutines: a chat generator with promise methods yield_value/return_value and await_transform, an interleave generator turned into a proper range by adding a custom iterator, and a simple cooperative scheduler that stores void handles in a std::list and resumes tasks round robin. Code uses std::coroutine_handle and suspend_always/suspend_never, shows heap allocation of the coroutine frame, and demonstrates that generators, range-based for iteration and a scheduler all compile and run as expected.

AI-written summary · about

  1. 0:00Introduction to C++ coroutines
  2. 2:39Functions vs coroutines control flow
  3. 6:11What are coroutines
  4. 11:33Coroutine elements in C++
  5. 15:45Code simplicity note
  6. 16:32First coroutine chat example
  7. 27:41Coroutine handle and promise type
  8. 34:22Tasks and generators defined
  9. 35:28Interleaving vectors with coroutines
  10. 43:45Range-based for loop support
  11. 47:18Scheduling multiple tasks
  12. 53:22Global scheduler and co_await
  13. 56:38Summary and next steps
  14. 58:12Q&A on stack and memory
~/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.