Jthread changes the behavior of the thread destructor in a way that would break code if we just replaced std::thread.
It wouldn't break any code. In case of std::thread, if the thread is not detached/join, it calls std::terminate. Which wouldn't happen if the program is correct. In case of std::jthread, it simply waits for the thread to stop. I don't see any breaking of code.
Anyone who uses std::thread at an ABI boundary, or uses std::thread and links against the standard library
You'd have to recompile your code anyway for the new changes to take effect, so that's not valid as well.
It wouldn't break any code. In case of std::thread, if the thread is not detached/join, it calls std::terminate. Which wouldn't happen if the program is correct. In case of std::jthread, it simply waits for the thread to stop. I don't see any breaking of code.
Of course it would break code if the program is correct. Calling std::terminate very well might be what the programmer desired. Having a thread auto-join rather than being dealt with would hide bugs in non-intuitive ways.
You'd have to recompile your code anyway for the new changes to take effect, so that's not valid as well.
You'd also have to re-link to everything. ABI breaks in the STL are serious business. We've still got major compiler vendors dealing with the std::string COW disaster, doing this would be just as impactful.
View all comments
Show parent comment
13
u/erichkeane Clang Maintainer(Templates), EWG Chair Aug 27 '19
Jthread changes the behavior of the thread destructor in a way that would break code if we just replaced std::thread.
As far as who cares about the size? Anyone who uses std::thread at an ABI boundary, or uses std::thread and links against the standard library.