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

High-performance thread pool with built-in error handling. 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 distribute_across_cpus () -> expected< void, std::error_code >
 Distribute threads across CPUs.
void shutdown ()
 Shutdown the pool.
void wait_for_tasks ()
 Wait for all tasks to complete.
auto size () const noexcept -> size_t
 Get pool size.
auto pending_tasks () const -> size_t
 Get pending task count.

Detailed Description

High-performance thread pool with built-in error handling.

Extends HighPerformancePool with automatic exception catching and error callbacks.

Definition at line 15 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 18 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 83 of file thread_pool_with_errors.hpp.

◆ clear_error_callbacks()

void threadschedule::HighPerformancePoolWithErrors::clear_error_callbacks ( )
inline

Clear all error callbacks.

Definition at line 91 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 131 of file thread_pool_with_errors.hpp.

◆ distribute_across_cpus()

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

Distribute threads across CPUs.

Definition at line 140 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 99 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 123 of file thread_pool_with_errors.hpp.

References threadschedule::HighPerformancePool::get_statistics().

◆ pending_tasks()

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

Get pending task count.

Definition at line 172 of file thread_pool_with_errors.hpp.

◆ pool()

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

Get the underlying pool.

Definition at line 115 of file thread_pool_with_errors.hpp.

◆ reset_error_count()

void threadschedule::HighPerformancePoolWithErrors::reset_error_count ( )
inline

Reset error count.

Definition at line 107 of file thread_pool_with_errors.hpp.

◆ shutdown()

void threadschedule::HighPerformancePoolWithErrors::shutdown ( )
inline

Shutdown the pool.

Definition at line 148 of file thread_pool_with_errors.hpp.

◆ size()

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

Get pool size.

Definition at line 164 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 27 of file thread_pool_with_errors.hpp.

◆ 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

Submit a task with a description for better error messages.

Definition at line 54 of file thread_pool_with_errors.hpp.

◆ wait_for_tasks()

void threadschedule::HighPerformancePoolWithErrors::wait_for_tasks ( )
inline

Wait for all tasks to complete.

Definition at line 156 of file thread_pool_with_errors.hpp.


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