C++ 中多线程和异常安全之间的紧张关系是什么?是否有好的指导方针可供遵循?线程是否因未捕获的异常而终止?
最佳答案
C++0x 将有 Language Support for Transporting Exceptions between Threads这样当工作线程抛出异常时,生成线程可以捕获或重新抛出它。
来自提案:
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 );
}
关于c++ - 编写多线程异常安全代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/329061/