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

Elastic executor for blocking future-waits. More...

#include <future_wait_pool.hpp>

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

Public Member Functions

 FutureWaitPool (FutureWaitPoolOptions opts={}, ThreadManager *manager=nullptr)
 
 FutureWaitPool (const FutureWaitPool &)=delete
 
FutureWaitPooloperator= (const FutureWaitPool &)=delete
 
 FutureWaitPool (FutureWaitPool &&) noexcept=default
 
FutureWaitPooloperator= (FutureWaitPool &&) noexcept=default
 
 ~FutureWaitPool () override=default
 
void execute (std::function< void()> task) override
 
std::string_view name () const noexcept override
 
template<class T >
Future< T > add (std::future< T > fut)
 Adopt a std::future<T>.
 
template<class T >
Future< T > add (std::shared_future< T > fut)
 Adopt a std::shared_future<T>.
 
template<class Fn >
requires std::invocable<Fn>
auto add_blocking (Fn &&fn) -> Future< std::invoke_result_t< Fn > >
 Run an arbitrary blocking callable on the wait pool, returning a Future<R>.
 
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
 
ThreadPoolpool () const noexcept
 
void shutdown () const
 
void shutdown_now () const
 
void join () const
 
bool is_shutting_down () const noexcept
 
bool is_terminated () const noexcept
 
- Public Member Functions inherited from threadman::IExecutor
virtual ~IExecutor ()=default
 

Static Public Member Functions

static const comms::DisplayInfo & display_info ()
 

Detailed Description

Elastic executor for blocking future-waits.

Owns its backing ThreadPool. Move-only (the inner pool lives on the heap, so the registered pool pointer stays valid across moves). Also satisfies IExecutor, so it can be passed anywhere an executor is expected.

Constructor & Destructor Documentation

◆ FutureWaitPool() [1/3]

threadman::FutureWaitPool::FutureWaitPool ( FutureWaitPoolOptions  opts = {},
ThreadManager manager = nullptr 
)
inlineexplicit

◆ FutureWaitPool() [2/3]

threadman::FutureWaitPool::FutureWaitPool ( const FutureWaitPool )
delete

◆ FutureWaitPool() [3/3]

threadman::FutureWaitPool::FutureWaitPool ( FutureWaitPool &&  )
defaultnoexcept

◆ ~FutureWaitPool()

threadman::FutureWaitPool::~FutureWaitPool ( )
overridedefault

Member Function Documentation

◆ add() [1/2]

template<class T >
Future< T > threadman::FutureWaitPool::add ( std::future< T >  fut)
inline

Adopt a std::future<T>.

The blocking get() runs on a pool worker; the returned Future<T> is satisfied with its value or its exception. Move-only T is supported (the value is moved out of the std::future).

◆ add() [2/2]

template<class T >
Future< T > threadman::FutureWaitPool::add ( std::shared_future< T >  fut)
inline

Adopt a std::shared_future<T>.

Same semantics as the std::future overload; the value is copied out (shared futures require copyable T).

◆ add_blocking()

template<class Fn >
requires std::invocable<Fn>
auto threadman::FutureWaitPool::add_blocking ( Fn &&  fn) -> Future<std::invoke_result_t<Fn>>
inline

Run an arbitrary blocking callable on the wait pool, returning a Future<R>.

Convenience for "this work blocks; give it elastic capacity" without first wrapping it in a std::future.

◆ core_worker_count()

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

◆ display_info()

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

◆ execute()

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

Implements threadman::IExecutor.

◆ id()

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

◆ is_shutting_down()

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

◆ is_terminated()

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

◆ join()

void threadman::FutureWaitPool::join ( ) const
inline

◆ max_worker_count()

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

◆ name()

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

Implements threadman::IExecutor.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

FutureWaitPool & threadman::FutureWaitPool::operator= ( FutureWaitPool &&  )
defaultnoexcept

◆ pool()

ThreadPool & threadman::FutureWaitPool::pool ( ) const
inlinenoexcept

◆ shutdown()

void threadman::FutureWaitPool::shutdown ( ) const
inline

◆ shutdown_now()

void threadman::FutureWaitPool::shutdown_now ( ) const
inline

◆ snapshot_workers()

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

◆ stats()

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

◆ worker_count()

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

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