Why and How we fixed std::thread by std::jthread - Nicolai Josuttis [ C++ on Sea 2020 ]
cpponsea
0:00 / 0:00
Why and How we fixed std::thread by std::jthread - Nicolai Josuttis [ C++ on Sea 2020 ]
6 533 просмотра · 6 лет назад
cpponsea
18,1 тыс. подписчиков
6 533 просмотра · 6 лет назад
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.
-------
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.
-------
C++ on Sea is an annual c++ and coding conference, usually held in Folkestone, Kent in the UK. The 2020 conference was moved to a virtual event due to social distancing requirements.
Produced and Edited by Digital Medium Ltd: https://events.digital-medium.co.uk
Enquiries: events@digital-medium.co.uk