threadman 0.1.0
Header-only C++23 managed threads, dynamic pools, futures, and executors
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
threadman::ThreadPool Class Referencefinal

#include <thread_pool.hpp>

Inheritance diagram for threadman::ThreadPool:
Inheritance graph
[legend]
Collaboration diagram for threadman::ThreadPool:
Collaboration graph
[legend]

Public Member Functions

 ThreadPool (ThreadPoolOptions opts={})
 
 ~ThreadPool () override
 
 ThreadPool (const ThreadPool &)=delete
 
ThreadPooloperator= (const ThreadPool &)=delete
 
 ThreadPool (ThreadPool &&)=delete
 
ThreadPooloperator= (ThreadPool &&)=delete
 
void execute (std::function< void()> task) override
 
std::string_view name () const noexcept override
 
template<class Fn >
requires std::invocable<Fn>
auto submit (Fn &&f) -> Future< std::invoke_result_t< Fn > >
 
template<class Fn >
requires std::invocable<Fn>
auto submit_named (std::string task_name, Fn &&f) -> Future< std::invoke_result_t< Fn > >
 
template<class Fn >
requires std::invocable<Fn, std::stop_token>
auto submit_stoppable (Fn &&f) -> Future< std::invoke_result_t< Fn, std::stop_token > >
 
void shutdown ()
 
void shutdown_now ()
 
void join ()
 
bool is_shutting_down () const noexcept
 
bool is_terminated () const noexcept
 
std::uint64_t id () const noexcept
 
std::size_t worker_count () const noexcept
 
std::size_t core_worker_count () const noexcept
 
std::size_t max_worker_count () const noexcept
 
ThreadPoolStats stats () const
 
std::vector< ThreadSnapshotsnapshot_workers () const
 
std::vector< TaskSnapshotsnapshot_recent_tasks () const
 
std::vector< TaskSnapshotsnapshot_queued_tasks () const
 
int scale_tick (std::chrono::steady_clock::time_point now)
 Driven by ThreadManager housekeeper. Returns net worker change.
 
std::vector< StuckTaskEventdetect_stuck_tasks (std::chrono::steady_clock::time_point now) const
 Driven by ThreadManager housekeeper.
 
- Public Member Functions inherited from threadman::IExecutor
virtual ~IExecutor ()=default
 

Static Public Member Functions

static const comms::DisplayInfo & display_info ()
 

Constructor & Destructor Documentation

◆ ThreadPool() [1/3]

threadman::ThreadPool::ThreadPool ( ThreadPoolOptions  opts = {})
inlineexplicit

◆ ~ThreadPool()

threadman::ThreadPool::~ThreadPool ( )
inlineoverride

◆ ThreadPool() [2/3]

threadman::ThreadPool::ThreadPool ( const ThreadPool )
delete

◆ ThreadPool() [3/3]

threadman::ThreadPool::ThreadPool ( ThreadPool &&  )
delete

Member Function Documentation

◆ core_worker_count()

std::size_t threadman::ThreadPool::core_worker_count ( ) const
inlinenoexcept

◆ detect_stuck_tasks()

std::vector< StuckTaskEvent > threadman::ThreadPool::detect_stuck_tasks ( std::chrono::steady_clock::time_point  now) const
inline

Driven by ThreadManager housekeeper.

Reports running tasks past stuck_task_threshold.

◆ display_info()

static const comms::DisplayInfo & threadman::ThreadPool::display_info ( )
inlinestatic

◆ execute()

void threadman::ThreadPool::execute ( std::function< void()>  task)
inlineoverridevirtual

Implements threadman::IExecutor.

◆ id()

std::uint64_t threadman::ThreadPool::id ( ) const
inlinenoexcept

◆ is_shutting_down()

bool threadman::ThreadPool::is_shutting_down ( ) const
inlinenoexcept

◆ is_terminated()

bool threadman::ThreadPool::is_terminated ( ) const
inlinenoexcept

◆ join()

void threadman::ThreadPool::join ( )
inline

◆ max_worker_count()

std::size_t threadman::ThreadPool::max_worker_count ( ) const
inlinenoexcept

◆ name()

std::string_view threadman::ThreadPool::name ( ) const
inlineoverridevirtualnoexcept

Implements threadman::IExecutor.

◆ operator=() [1/2]

ThreadPool & threadman::ThreadPool::operator= ( const ThreadPool )
delete

◆ operator=() [2/2]

ThreadPool & threadman::ThreadPool::operator= ( ThreadPool &&  )
delete

◆ scale_tick()

int threadman::ThreadPool::scale_tick ( std::chrono::steady_clock::time_point  now)
inline

Driven by ThreadManager housekeeper. Returns net worker change.

◆ shutdown()

void threadman::ThreadPool::shutdown ( )
inline

◆ shutdown_now()

void threadman::ThreadPool::shutdown_now ( )
inline

◆ snapshot_queued_tasks()

std::vector< TaskSnapshot > threadman::ThreadPool::snapshot_queued_tasks ( ) const
inline

◆ snapshot_recent_tasks()

std::vector< TaskSnapshot > threadman::ThreadPool::snapshot_recent_tasks ( ) const
inline

◆ snapshot_workers()

std::vector< ThreadSnapshot > threadman::ThreadPool::snapshot_workers ( ) const
inline

◆ stats()

ThreadPoolStats threadman::ThreadPool::stats ( ) const
inline

◆ submit()

template<class Fn >
requires std::invocable<Fn>
auto threadman::ThreadPool::submit ( Fn &&  f) -> Future<std::invoke_result_t<Fn>>

◆ submit_named()

template<class Fn >
requires std::invocable<Fn>
auto threadman::ThreadPool::submit_named ( std::string  task_name,
Fn &&  f 
) -> Future<std::invoke_result_t<Fn>>

◆ submit_stoppable()

template<class Fn >
requires std::invocable<Fn, std::stop_token>
auto threadman::ThreadPool::submit_stoppable ( Fn &&  f) -> Future<std::invoke_result_t<Fn, std::stop_token>>

◆ worker_count()

std::size_t threadman::ThreadPool::worker_count ( ) const
inlinenoexcept

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