Topic: which thread calls std::terminate?


Author: restor <akrzemi1@gmail.com>
Date: Mon, 21 Jun 2010 12:01:52 CST
Raw View
Hi,
In C++0x, in a multi-threaded program, is it specified (in each case
std::terminate is needed) which thread calls std::terminate? In some
cases, like an "unfortunate re-throw" it is natural to point the
candidate thread. But if thread ends due to an exception that remains
uncaught, I am not tat sure. Does the standard regulate that?
This difference is visible when the "termination handler" uses a
thread_local variable.

Regards,
&rzej

--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use
mailto:std-c++@netlab.cs.rpi.edu<std-c%2B%2B@netlab.cs.rpi.edu>
]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: CornedBee <wasti.redl@gmx.net>
Date: Thu, 24 Jun 2010 12:23:12 CST
Raw View
On Jun 21, 8:01 pm, restor <akrze...@gmail.com> wrote:
> Hi,
> In C++0x, in a multi-threaded program, is it specified (in each case
> std::terminate is needed) which thread calls std::terminate? In some
> cases, like an "unfortunate re-throw" it is natural to point the
> candidate thread. But if thread ends due to an exception that remains
> uncaught, I am not tat sure.

Why not? An exception that remains uncaught must have been thrown by a
specific thread. Why would any other thread call std::terminate?
The C++0x draft does not specify what thread calls std::terminate, but
the list of situations in which it is called is easy to resolve: every
situation involves one specific thread being in the situation that
leads to std::terminate being called, so it's pretty obvious that this
thread will call it. It's also implied by the comments about stack
unwinding.

Sebastian


--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use
mailto:std-c++@netlab.cs.rpi.edu<std-c%2B%2B@netlab.cs.rpi.edu>
]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]