What We’ve Been Awaiting For? - How to Build a C++ Coroutine Type
summary
Shows how to build a concrete C++ coroutine type that actually downloads web pages using libcurl multi API, implements a tiny scheduler that tracks running vs blocked coroutine counts, and exposes promise-style combinators (all/any/race) plus retries and optional results. Code materializes lazy ranges to start all fetches, stores results in the promise frame, and resumes coroutines from the multi-handle loop; the demo fetches pages, extracts URLs with CTRE, downloads resources, and the system successfully joins and returns the vector of contents.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 1:05JavaScript coroutines
- 5:06C++ coroutines motivation
- 8:03C++ coroutine basics
- 13:07Coroutine mechanics
- 22:26Suspension points
- 25:42Promise type
- 31:47Coroutine resumption
- 35:21Scheduler integration
- 41:40Lazy perform implementation
- 44:10libcurl async API
- 45:37Fetch function
- 47:29Promise composition
- 51:20Search engine demo
- 53:44Library overview
- 54:05Q&A
related talks
48m“Coroutines: what can't they do?”
01h 20mCoroutines for Dummies
57mC++ Coroutines: Under the covers
58m“C++ Coroutines - a negative overhead abstraction"
56mGenerators, Coroutines and Other Brain Unrolling Sweetness
01h 05mImplementing async with coroutines and fibers - project Loom in C#
01h 35mNo Compiler Required - Hand-Rolling C++20 Coroutines in C++17
31mGenerators, Coroutines and Other Brain Unrolling Sweetness
