Concurrent Details Matter - Why and How we fixed std::thread by std::jthread
Nicolai Josuttis
With C++20 we will have a new basic thread class, std::jthread
.
It will fix some basic flaws of std::thread
, because
std::thread
was not designed as an easy-to-use RAII type and lacks
support for stopping a running thread.
Sounds easy: we only have to pass a parameter to signal cancellation and implement a destructor that performs this request before it joins. But regarding concurrency, nothing is easy in programming. The devil is in the details, especially in C++.
So this is not a talk about jthread
.
It is a talk about how implementing a pretty simple additional
concurrent requirement became a tricky task with many traps.
You don't want to do it yourself.
-
Nico is also running a full day workshop on Move Semantics just after the main conference.
Nicolai Josuttis
Nicolai Josuttis (www.josuttis.com) is well known in the C++ Community for speaking and writing with authority about C++ (being the author of "The C++ Standard Library", "C++ Templates" (coauthor), and "C+++17 - The Complete Guide") but is also an innovative presenter. He is an active member of C++ standardization committee for more than 20 years now.