void _esthread_helper std function void try catch std exception report

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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))...);
}