void _esthread_helper(std::function<void()> f) {
try {
f();
} catch (std::exception &e) {
report_exception(e);
} catch (...) {
report_current_exception();
throw; // that should be cancellation request, it will kill the current thread only.
// Otherwise that's something that should've never left thread body.
}
}
template <typename _Callable, typename... _Args>
std::thread make_esthread(_Callable&& __f, _Args&&... __args) {
void _esthread_helper(std::function<void()> f);
return std::thread(_esthread_helper,
std::bind(std::forward<_Callable>(__f),
std::forward<_Args>(__args))...);
}