|
ThreadSchedule 1.0.0
Modern C++ thread management library
|
Central registry and dispatcher for task-error callbacks. More...
#include <error_handler.hpp>
Public Member Functions | |
| auto | add_callback (ErrorCallback callback) -> size_t |
| Register an error callback. | |
| void | clear_callbacks () |
| Remove all registered error callbacks. | |
| void | handle_error (TaskError const &error) |
| Dispatch an error to all registered callbacks. | |
| auto | error_count () const -> size_t |
| Return the total number of errors handled since the last reset. | |
| void | reset_error_count () |
| Reset the cumulative error count to zero. | |
Central registry and dispatcher for task-error callbacks.
ErrorHandler maintains an ordered list of ErrorCallback functions and invokes them whenever a task reports a failure through handle_error().
std::mutex, so the handler can be shared across threads (typically via std::shared_ptr).remove_callback() – only clear_callbacks() removes all callbacks at once. The error count returned by error_count() is monotonically increasing and is only reset by an explicit call to reset_error_count(). Definition at line 119 of file error_handler.hpp.
|
inline |
Register an error callback.
| callback | Callable to invoke when a task throws. |
Definition at line 130 of file error_handler.hpp.
|
inline |
Remove all registered error callbacks.
After this call, handle_error() will still increment the error count but no callbacks will be invoked.
Definition at line 143 of file error_handler.hpp.
|
inlinenodiscard |
Return the total number of errors handled since the last reset.
The count is monotonically increasing and is only set back to zero by an explicit call to reset_error_count().
Definition at line 184 of file error_handler.hpp.
|
inline |
Dispatch an error to all registered callbacks.
Increments the internal error counter and then invokes every registered callback in order. If any callback throws, the exception is caught and silently discarded so that subsequent callbacks still run.
| error | Diagnostic information about the failed task. |
Definition at line 158 of file error_handler.hpp.
|
inline |
Reset the cumulative error count to zero.
Definition at line 193 of file error_handler.hpp.