|
ThreadSchedule 2.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. | |
| auto | remove_callback (size_t id) -> bool |
| Remove a single callback by its ID. | |
| auto | has_callback (size_t id) const -> bool |
| Check whether a callback with the given ID is registered. | |
| 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).Definition at line 142 of file error_handler.hpp.
|
inline |
Register an error callback.
| callback | Callable to invoke when a task throws. |
Definition at line 151 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 186 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 226 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 insertion 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 201 of file error_handler.hpp.
|
inlinenodiscard |
Check whether a callback with the given ID is registered.
Definition at line 174 of file error_handler.hpp.
|
inline |
Remove a single callback by its ID.
| id | The ID returned by add_callback(). |
true if the callback was found and removed, false otherwise. Definition at line 165 of file error_handler.hpp.
|
inline |
Reset the cumulative error count to zero.
Definition at line 235 of file error_handler.hpp.