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

Simple high-performance thread pool using single queue with optimized locking. More...

#include <thread_pool.hpp>

Classes

struct  Statistics

Public Types

using Task = std::function<void()>

Public Member Functions

 FastThreadPool (size_t num_threads=std::thread::hardware_concurrency())
 FastThreadPool (FastThreadPool const &)=delete
auto operator= (FastThreadPool const &) -> FastThreadPool &=delete
template<typename F, typename... Args>
auto submit (F &&f, Args &&... args) -> std::future< std::invoke_result_t< F, Args... > >
 Optimized task submission with minimal locking.
template<typename Iterator>
auto submit_batch (Iterator begin, Iterator end) -> std::vector< std::future< void > >
 Efficient batch processing.
void shutdown ()
auto configure_threads (std::string const &name_prefix, SchedulingPolicy policy=SchedulingPolicy::OTHER, ThreadPriority priority=ThreadPriority::normal()) -> bool
auto distribute_across_cpus () -> bool
auto size () const noexcept -> size_t
auto pending_tasks () const -> size_t
auto get_statistics () const -> Statistics

Detailed Description

Simple high-performance thread pool using single queue with optimized locking.

Alternative implementation for cases where work-stealing overhead is not justified. Uses a single queue with optimized batch processing and minimal locking.

Best for: Medium workloads (100-10k tasks), consistent task patterns where work-stealing complexity isn't needed but better performance than basic ThreadPool is desired.

Definition at line 603 of file thread_pool.hpp.

Member Typedef Documentation

◆ Task

using threadschedule::FastThreadPool::Task = std::function<void()>

Definition at line 606 of file thread_pool.hpp.

Constructor & Destructor Documentation

◆ FastThreadPool()

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

Definition at line 618 of file thread_pool.hpp.

◆ ~FastThreadPool()

threadschedule::FastThreadPool::~FastThreadPool ( )
inline

Definition at line 633 of file thread_pool.hpp.

Member Function Documentation

◆ configure_threads()

auto threadschedule::FastThreadPool::configure_threads ( std::string const & name_prefix,
SchedulingPolicy policy = SchedulingPolicy::OTHER,
ThreadPriority priority = ThreadPriority::normal() ) -> bool
inline

Definition at line 716 of file thread_pool.hpp.

◆ distribute_across_cpus()

auto threadschedule::FastThreadPool::distribute_across_cpus ( ) -> bool
inline

Definition at line 739 of file thread_pool.hpp.

◆ get_statistics()

auto threadschedule::FastThreadPool::get_statistics ( ) const -> Statistics
inline

Definition at line 770 of file thread_pool.hpp.

◆ pending_tasks()

auto threadschedule::FastThreadPool::pending_tasks ( ) const -> size_t
inline

Definition at line 764 of file thread_pool.hpp.

◆ shutdown()

void threadschedule::FastThreadPool::shutdown ( )
inline

Definition at line 694 of file thread_pool.hpp.

◆ size()

auto threadschedule::FastThreadPool::size ( ) const -> size_t
inlinenoexcept

Definition at line 759 of file thread_pool.hpp.

◆ submit()

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

Optimized task submission with minimal locking.

Definition at line 642 of file thread_pool.hpp.

◆ submit_batch()

template<typename Iterator>
auto threadschedule::FastThreadPool::submit_batch ( Iterator begin,
Iterator end ) -> std::vector<std::future<void>>
inline

Efficient batch processing.

Definition at line 668 of file thread_pool.hpp.


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