When using boost::thread::interrupt(), do you *need* to catch the thread_interrupted exception?

落花浮王杯 提交于 2019-12-03 13:12:48

The exception is just like any other C++ exception. If you choose not to catch it, it will cause the same effect as any other unhandled exception.

If left uncaught, it will not propagate to the main thread, but could cause other undesirable behaviour. On Visual C++, by default this will terminate your process, for example.

In general, defensive programming practice would dictate that you should catch any exception your code can throw - just the same as you would check for error from an OS API that you called.

There's a backgrounder on interruption here by the person who wrote a lot of the Boost.Thread code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!