Topic: std::terminate per thread - std vs. MS practice?


Author: "Martin B." <0xCDCDCDCD@gmx.at>
Date: Thu, 31 Mar 2011 16:33:21 CST
Raw View
Hi!

Since C++ never talked about threads, MS was quite free to specify[1]:

   set_terminate (CRT)
   -------------------
   (Visual Studio 2010 )

   Installs your own termination routine
   to be called by terminate.
   ...

   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.

Now, looking at the latest std draft (N3242):
   18.8.3.1 Type terminate_handler

   2 Required behavior: A terminate_handler shall
     terminate execution of the program without
     returning to the caller.

Does anyone have any idea whether the wording for the
terminate_handler might be too strict now that we have threads in the
std?

cheers,
Martin


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Dragan Milenkovic <dragan@plusplus.rs>
Date: Fri, 1 Apr 2011 07:52:35 CST
Raw View
On 04/01/2011 12:33 AM, Martin B. wrote:
>
> Hi!
>
> Since C++ never talked about threads, MS was quite free to specify[1]:
>
> set_terminate (CRT)
> -------------------
> (Visual Studio 2010 )
>
> Installs your own termination routine
> to be called by terminate.
> ...
>
> 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.
>
> Now, looking at the latest std draft (N3242):
> 18.8.3.1 Type terminate_handler
>
> 2 Required behavior: A terminate_handler shall
> terminate execution of the program without
> returning to the caller.
>
> Does anyone have any idea whether the wording for the
> terminate_handler might be too strict now that we have threads in the
> std?

I didn't find in the standard that set_terminate will
set a handler function globally. Perhaps it is allowed
for it to be set on a per-thread level (I may be mistaken).
Of course, it has and always will terminate the whole program.

It should be specified, though...

--
Dragan


[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Fri, 1 Apr 2011 07:52:14 CST
Raw View
Am 01.04.2011 00:33, schrieb Martin B.:
>
> Hi!
>
> Since C++ never talked about threads, MS was quite free to specify[1]:
>
> set_terminate (CRT)
> -------------------
> (Visual Studio 2010 )
>
> Installs your own termination routine
> to be called by terminate.
> ...
>
> 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.
>
> Now, looking at the latest std draft (N3242):
> 18.8.3.1 Type terminate_handler
>
> 2 Required behavior: A terminate_handler shall
> terminate execution of the program without
> returning to the caller.
>
> Does anyone have any idea whether the wording for the
> terminate_handler might be too strict now that we have threads in the
> std?

The wording of the current draft reflects the intention
of the committee that there shall be no data race and
no per-thread local terminate handler, see the proposal

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3189.htm

which became accepted in Batavia 2010. Per-thread handlers are often
hard to manage and it is always possible to define a single handler
that again queries a thread-local to get the actual handler, if you
really want, but not vice versa.

HTH & Greetings from Bremen,

Daniel Kr   gler




--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]