Coroutines: Don’t try this at home

Lieven de Cock

⏱ 90 minute session
beginner
intermediate
advanced
11:30-13:00, Saturday, 20th April 2024
In C++20 we got the core language feature “coroutines”. Mostly oriented to the advanced c++ programmers, and not for the mere mortals, since it requires a lot of boilerplate one would not like to write. It provides the fundamentals to further build upon. Unfortunately the STL library did not build on it yet, more was to come in C++23. In C++23 we will only get one follow up: std::generator. So let’s revisit coroutines. What are they? A function that can be suspended and resumed. Easily said, but how to make use of it and write that boilerplate after all. We will look at the coroutine from 2 different angles: the user code and the compiler, and we will inspect what each wants or would like to have, and where we need to glue them together and what is needed for that purpose. We will give insights on topics like: coroutine frame, couroutine handle, promise_type, awaiters, awaitables, the interface or api.
🏷 coroutines
🏷 promise_type
🏷 awaiters

Lieven de Cock

Lieven is a passionate software developer, architect, team lead,manager, with 25+ years of experience, Passionate about C++, Software Craftsmanship and Clean Code. The career started in the Text-To-Speech domain (yes, I still recognize certain things programmed 25 years ago, in Alexa and friends), moving on to Video recognition technology for Traffic, and the last 14 years active in the Satellite Communication industry. Lieven also contributes to several open source projects, and is the lead developer of the open source IDE Code::Blocks. He is also the lead coach of the Coderdojo division in Ghent, Belgium where he lives. There is an ever growing record collection, always crying for attention to be put on the turn-tables, and many evenings are marked in the agenda for visiting life concerts. If in presented code snippets the number 242 might pop-up, this is no coincidence, paying tribute to Front 242.