|
ThreadSchedule 3.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 (error_callback callback) -> size_t |
| Register an error callback. | |
| template<typename Callback , std::enable_if_t<!std::is_same_v<::threadschedule::detail::remove_cvref_t< Callback >, error_callback >, int > = 0> | |
| auto | add_callback (Callback &&callback) -> size_t |
| 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 (task_error 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.
error_handler maintains an ordered list of error_callback 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 55 of file error_handler.hpp.
|
inline |
Definition at line 74 of file error_handler.hpp.
References threadschedule::detail::make_copyable_function().
|
inline |
Register an error callback.
| callback | Callable to invoke when a task throws. |
Definition at line 65 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 112 of file error_handler.hpp.
|
inline |
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 160 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 128 of file error_handler.hpp.
|
inline |
Check whether a callback with the given ID is registered.
Definition at line 99 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 89 of file error_handler.hpp.
|
inline |
Reset the cumulative error count to zero.
Definition at line 170 of file error_handler.hpp.