C++, is set_terminate local to every thread?

前端 未结 4 842
无人共我
无人共我 2021-02-07 14:11

Should set_terminate/get_terminate set a different terminate exception processor for several threads in C++ 2011 or C++ 2003?

E.g. if I have pr

4条回答
  •  滥情空心
    2021-02-07 14:32

    C2003 has no threads, any thread support is a vendor extension so only vendor-supplied documentation has the answer. If the handler is per thread, the documentation ought to say that. No implementation I know does it.

    C++2011 says nothing about per-thread nature of the terminate handler. It would make little sense to maintain it per thread, because you cannot kill a thread in C++11. And for a good reason too (google kill+thread+c++11). So whatever you do, the program must terminate. It looks like having different ways to terminate the program depending on the thread that requested it is not a feature anyone needs.

提交回复
热议问题