Better Threading support in C++20

Lieven de Cock

⏱ 75 mins
intermediate
11:00-12:15, Wednesday, 25th June 2025

We got threading support by the language and library in C++11. There were however a few things missing, like RAII for a thread object, or a nice way to stop a thread, or to request it to stop. Similar problem, how do we stop a ‘waiting’ condition variable. Most developers have solved these problems with home made solutions. C++20 brings standardized solutions to the table. Next to that we also get some new synchronization facilities like barrier/latch/semaphore, all nice additions. There is no longer a need to re-invent the wheel or reach out to 3rd-party libraries. We will look at all these new little tools and investigate on how to use them. So register your stop callback, and by the end of the talk we will request our source to stop, and in our ‘cooperative cancellation’ scheme, do not forget to keep an eye on your stop token.

Lieven de Cock

Lieven is a passionate software developer, architect, team lead, manager, with 30 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 nearly 30 years ago, in Alexa and friends), moving on to Video recognition technology for Traffic control systems, and the last 15 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.