Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing Multithreaded Exception-Safe Code

What are the tensions between multithreading and exception-safety in C++? Are there good guidelines to follow? Does a thread terminate because of an uncaught exception?

like image 347
Nicola Bonelli Avatar asked Nov 30 '08 16:11

Nicola Bonelli


1 Answers

C++0x will have Language Support for Transporting Exceptions between Threads so that when a worker thread throws an exception the spawning thread can catch or rethrow it.

From the proposal:

namespace std {

    typedef unspecified exception_ptr;

    exception_ptr current_exception();
    void rethrow_exception( exception_ptr p );

    template< class E > exception_ptr copy_exception( E e );
}
like image 98
Motti Avatar answered Oct 09 '22 18:10

Motti