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

HighPerformancePool combined with an ErrorHandler. More...

#include <thread_pool_with_errors.hpp>

Public Member Functions

 HighPerformancePoolWithErrors (size_t num_threads=std::thread::hardware_concurrency())
template<typename F, typename... Args>
auto submit (F &&f, Args &&... args) -> FutureWithErrorHandler< std::invoke_result_t< F, Args... > >
 Submit a task with automatic error handling.
template<typename F, typename... Args>
auto submit_with_description (std::string const &description, F &&f, Args &&... args) -> FutureWithErrorHandler< std::invoke_result_t< F, Args... > >
 Submit a task with a description for better error messages.
auto add_error_callback (ErrorCallback callback) -> size_t
 Add a global error callback for all tasks.
void clear_error_callbacks ()
 Clear all error callbacks.
auto error_count () const -> size_t
 Get total error count.
void reset_error_count ()
 Reset error count.
auto pool () -> HighPerformancePool &
 Get the underlying pool.
auto get_statistics () const -> HighPerformancePool::Statistics
 Get statistics from underlying pool.
auto configure_threads (std::string const &name_prefix, SchedulingPolicy policy=SchedulingPolicy::OTHER, ThreadPriority priority=ThreadPriority::normal()) -> expected< void, std::error_code >
 Configure threads.
auto set_affinity (ThreadAffinity const &affinity) -> expected< void, std::error_code >
auto distribute_across_cpus () -> expected< void, std::error_code >
void shutdown ()
void wait_for_tasks ()
auto size () const noexcept -> size_t
auto pending_tasks () const -> size_t

Detailed Description

HighPerformancePool combined with an ErrorHandler.

Non-copyable, non-movable. Thread-safe (delegates to the underlying HighPerformancePool).

submit() wraps every task so that exceptions are both reported to the ErrorHandler (via registered callbacks) and re-thrown, making them accessible through the returned FutureWithErrorHandler. submit_with_description() additionally attaches a user-supplied description string to the error report for easier diagnostics.

See also
FutureWithErrorHandler, ErrorHandler, TaskError

Definition at line 24 of file thread_pool_with_errors.hpp.

Constructor & Destructor Documentation

◆ HighPerformancePoolWithErrors()

threadschedule::HighPerformancePoolWithErrors::HighPerformancePoolWithErrors ( size_t num_threads = std::thread::hardware_concurrency())
inlineexplicit

Definition at line 27 of file thread_pool_with_errors.hpp.

Member Function Documentation

◆ add_error_callback()

auto threadschedule::HighPerformancePoolWithErrors::add_error_callback ( ErrorCallback callback) -> size_t
inline

Add a global error callback for all tasks.

Definition at line 92 of file thread_pool_with_errors.hpp.

◆ clear_error_callbacks()

void threadschedule::HighPerformancePoolWithErrors::clear_error_callbacks ( )
inline

Clear all error callbacks.

Definition at line 100 of file thread_pool_with_errors.hpp.

◆ configure_threads()

auto threadschedule::HighPerformancePoolWithErrors::configure_threads ( std::string const & name_prefix,
SchedulingPolicy policy = SchedulingPolicy::OTHER,
ThreadPriority priority = ThreadPriority::normal() ) -> expected<void, std::error_code>
inline

Configure threads.

Definition at line 140 of file thread_pool_with_errors.hpp.

◆ distribute_across_cpus()

auto threadschedule::HighPerformancePoolWithErrors::distribute_across_cpus ( ) -> expected<void, std::error_code>
inline

Definition at line 151 of file thread_pool_with_errors.hpp.

◆ error_count()

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

Get total error count.

Definition at line 108 of file thread_pool_with_errors.hpp.

◆ get_statistics()

auto threadschedule::HighPerformancePoolWithErrors::get_statistics ( ) const -> HighPerformancePool::Statistics
inlinenodiscard

Get statistics from underlying pool.

Definition at line 132 of file thread_pool_with_errors.hpp.

References threadschedule::HighPerformancePool::get_statistics().

◆ pending_tasks()

auto threadschedule::HighPerformancePoolWithErrors::pending_tasks ( ) const -> size_t
inlinenodiscard

Definition at line 171 of file thread_pool_with_errors.hpp.

◆ pool()

auto threadschedule::HighPerformancePoolWithErrors::pool ( ) -> HighPerformancePool&
inlinenodiscard

Get the underlying pool.

Definition at line 124 of file thread_pool_with_errors.hpp.

◆ reset_error_count()

void threadschedule::HighPerformancePoolWithErrors::reset_error_count ( )
inline

Reset error count.

Definition at line 116 of file thread_pool_with_errors.hpp.

◆ set_affinity()

auto threadschedule::HighPerformancePoolWithErrors::set_affinity ( ThreadAffinity const & affinity) -> expected<void, std::error_code>
inline

Definition at line 146 of file thread_pool_with_errors.hpp.

◆ shutdown()

void threadschedule::HighPerformancePoolWithErrors::shutdown ( )
inline

Definition at line 156 of file thread_pool_with_errors.hpp.

◆ size()

auto threadschedule::HighPerformancePoolWithErrors::size ( ) const -> size_t
inlinenodiscardnoexcept

Definition at line 166 of file thread_pool_with_errors.hpp.

◆ submit()

template<typename F, typename... Args>
auto threadschedule::HighPerformancePoolWithErrors::submit ( F && f,
Args &&... args ) -> FutureWithErrorHandler<std::invoke_result_t<F, Args...>>
inline

Submit a task with automatic error handling.

Definition at line 36 of file thread_pool_with_errors.hpp.

References threadschedule::TaskError::exception, threadschedule::TaskError::thread_id, and threadschedule::TaskError::timestamp.

◆ submit_with_description()

template<typename F, typename... Args>
auto threadschedule::HighPerformancePoolWithErrors::submit_with_description ( std::string const & description,
F && f,
Args &&... args ) -> FutureWithErrorHandler<std::invoke_result_t<F, Args...>>
inline

◆ wait_for_tasks()

void threadschedule::HighPerformancePoolWithErrors::wait_for_tasks ( )
inline

Definition at line 161 of file thread_pool_with_errors.hpp.


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