ThreadSchedule 1.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
threadschedule::ErrorHandler Class Reference

Global error handler for thread pool tasks. More...

#include <error_handler.hpp>

Public Member Functions

auto add_callback (ErrorCallback callback) -> size_t
 Add an error callback.
void clear_callbacks ()
 Remove all error callbacks.
void handle_error (TaskError const &error)
 Handle an exception from a task.
auto error_count () const -> size_t
 Get total number of errors handled.
void reset_error_count ()
 Reset error count.

Detailed Description

Global error handler for thread pool tasks.

Allows registering callbacks that will be invoked when tasks throw exceptions. Multiple handlers can be registered and they will be called in order.

Definition at line 72 of file error_handler.hpp.

Member Function Documentation

◆ add_callback()

auto threadschedule::ErrorHandler::add_callback ( ErrorCallback callback) -> size_t
inline

Add an error callback.

Parameters
callbackFunction to call when a task throws
Returns
Handle (index) that can be used to remove the callback

Definition at line 80 of file error_handler.hpp.

◆ clear_callbacks()

void threadschedule::ErrorHandler::clear_callbacks ( )
inline

Remove all error callbacks.

Definition at line 90 of file error_handler.hpp.

◆ error_count()

auto threadschedule::ErrorHandler::error_count ( ) const -> size_t
inlinenodiscard

Get total number of errors handled.

Definition at line 121 of file error_handler.hpp.

◆ handle_error()

void threadschedule::ErrorHandler::handle_error ( TaskError const & error)
inline

Handle an exception from a task.

Parameters
errorError information

Definition at line 100 of file error_handler.hpp.

◆ reset_error_count()

void threadschedule::ErrorHandler::reset_error_count ( )
inline

Reset error count.

Definition at line 130 of file error_handler.hpp.


The documentation for this class was generated from the following file: