24thread_local std::vector<Handler_t> rootErrorHandlers;
28std::atomic<ErrorHandlerFunc_t> origHandler;
41 for (
int i = rootErrorHandlers.size()-1; i >= 0; --i) {
42 if (!rootErrorHandlers[i] (level, abort, location,
msg))
return;
45 origHandler.load() (
level, abort, location,
msg);
66 :
m_size (rootErrorHandlers.size()+1)
81 static std::once_flag flag;
82 std::call_once (flag, []() {
89 rootErrorHandlers.push_back (errhand);
100 if (
m_size != rootErrorHandlers.size()) std::abort();
101 rootErrorHandlers.pop_back();
static void errorHandler()
Run a MT piece of code with an alternate root error handler.
size_t m_size
For error checking.
~WithRootErrorHandler()
Destructor.
std::function< bool(int, Bool_t, const char *, const char *)> Handler_t
Type of handler to register.
WithRootErrorHandler(Handler_t errhand)
Temporarily install a thread-local root error handler.