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

#include <manager.hpp>

Classes

struct  Options
 
class  SubscriptionToken
 RAII handle returned by subscribe_*. More...
 

Public Types

using SummaryListener = std::function< void(const ManagerSummary &)>
 
using StuckTaskListener = std::function< void(const StuckTaskEvent &)>
 

Public Member Functions

 ThreadManager ()
 
 ThreadManager (Options opts)
 
 ~ThreadManager ()
 
 ThreadManager (const ThreadManager &)=delete
 
ThreadManageroperator= (const ThreadManager &)=delete
 
 ThreadManager (ThreadManager &&)=delete
 
ThreadManageroperator= (ThreadManager &&)=delete
 
void register_thread (const std::shared_ptr< ManagedThread::ControlBlock > &cb)
 
void unregister_thread (const std::uint64_t thread_id) noexcept
 
void register_pool (ThreadPool &p)
 
void unregister_pool (const std::uint64_t pool_id) noexcept
 
std::vector< ThreadSnapshotsnapshot_threads () const
 
std::optional< ThreadSnapshotfind_by_id (const std::uint64_t id) const
 
std::vector< ThreadSnapshotfind_by_name (const std::string_view name) const
 
std::vector< ThreadPoolStatssnapshot_pools () const
 
ManagerSummary build_summary () const
 
FutureWaitPool make_future_wait_pool (FutureWaitPoolOptions opts={})
 Create a FutureWaitPool attached to this manager.
 
ThreadPooldefault_pool ()
 
SubscriptionToken subscribe_summary (SummaryListener cb)
 
SubscriptionToken subscribe_stuck_tasks (StuckTaskListener cb)
 
void start_housekeeper ()
 
void stop_housekeeper () noexcept
 
bool housekeeper_running () const noexcept
 
std::size_t stuck_task_count () const noexcept
 Number of tasks currently flagged as stuck (and already reported) by the housekeeper.
 

Static Public Member Functions

static ThreadManagerinstance () noexcept
 
static const comms::DisplayInfo & display_info ()
 

Member Typedef Documentation

◆ StuckTaskListener

using threadman::ThreadManager::StuckTaskListener = std::function<void(const StuckTaskEvent&)>

◆ SummaryListener

using threadman::ThreadManager::SummaryListener = std::function<void(const ManagerSummary&)>

Constructor & Destructor Documentation

◆ ThreadManager() [1/4]

threadman::ThreadManager::ThreadManager ( )
inline

◆ ThreadManager() [2/4]

threadman::ThreadManager::ThreadManager ( Options  opts)
inlineexplicit

◆ ~ThreadManager()

threadman::ThreadManager::~ThreadManager ( )
inline

◆ ThreadManager() [3/4]

threadman::ThreadManager::ThreadManager ( const ThreadManager )
delete

◆ ThreadManager() [4/4]

threadman::ThreadManager::ThreadManager ( ThreadManager &&  )
delete

Member Function Documentation

◆ build_summary()

ManagerSummary threadman::ThreadManager::build_summary ( ) const
inline

◆ default_pool()

ThreadPool & threadman::ThreadManager::default_pool ( )
inline

◆ display_info()

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

◆ find_by_id()

std::optional< ThreadSnapshot > threadman::ThreadManager::find_by_id ( const std::uint64_t  id) const
inline

◆ find_by_name()

std::vector< ThreadSnapshot > threadman::ThreadManager::find_by_name ( const std::string_view  name) const
inline

◆ housekeeper_running()

bool threadman::ThreadManager::housekeeper_running ( ) const
inlinenoexcept

◆ instance()

static ThreadManager & threadman::ThreadManager::instance ( )
inlinestaticnoexcept

◆ make_future_wait_pool()

FutureWaitPool threadman::ThreadManager::make_future_wait_pool ( FutureWaitPoolOptions  opts = {})
inline

Create a FutureWaitPool attached to this manager.

The pool's backing ThreadPool registers here so the housekeeper drives its scaling; the caller owns the returned pool and its lifetime governs the workers.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ register_pool()

void threadman::ThreadManager::register_pool ( ThreadPool p)
inline

◆ register_thread()

void threadman::ThreadManager::register_thread ( const std::shared_ptr< ManagedThread::ControlBlock > &  cb)
inline

◆ snapshot_pools()

std::vector< ThreadPoolStats > threadman::ThreadManager::snapshot_pools ( ) const
inline

◆ snapshot_threads()

std::vector< ThreadSnapshot > threadman::ThreadManager::snapshot_threads ( ) const
inline

◆ start_housekeeper()

void threadman::ThreadManager::start_housekeeper ( )
inline

◆ stop_housekeeper()

void threadman::ThreadManager::stop_housekeeper ( )
inlinenoexcept

◆ stuck_task_count()

std::size_t threadman::ThreadManager::stuck_task_count ( ) const
inlinenoexcept

Number of tasks currently flagged as stuck (and already reported) by the housekeeper.

Returns to zero once those tasks finish — the housekeeper reconciles its internal dedup set every tick. Primarily for observability and tests.

◆ subscribe_stuck_tasks()

SubscriptionToken threadman::ThreadManager::subscribe_stuck_tasks ( StuckTaskListener  cb)
inline

◆ subscribe_summary()

SubscriptionToken threadman::ThreadManager::subscribe_summary ( SummaryListener  cb)
inline

◆ unregister_pool()

void threadman::ThreadManager::unregister_pool ( const std::uint64_t  pool_id)
inlinenoexcept

◆ unregister_thread()

void threadman::ThreadManager::unregister_thread ( const std::uint64_t  thread_id)
inlinenoexcept

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