C++, is set_terminate local to every thread?

前端 未结 4 844
无人共我
无人共我 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:56

    The standard doesn't exactly specify; [set.terminate] states only

    [...] the current handler function for terminating exception processing.

    but doesn't mention if "current" is global or per-thread. So it depends on the implementation.

    For example, in MSVC++: https://msdn.microsoft.com/en-us/library/t6fk7h29.aspx

    In a multithreaded environment, terminate functions are maintained separately for each thread. Each new thread needs to install its own terminate function. Thus, each thread is in charge of its own termination handling.

提交回复
热议问题