libcoro  1.0
Coroutine support library for C++20
Public Member Functions | Static Public Member Functions | List of all members
coro::thread_pool_t< CondVar > Class Template Reference

thread pool implementation More...

#include <thread_pool.h>

+ Collaboration diagram for coro::thread_pool_t< CondVar >:

Public Member Functions

 thread_pool_t (unsigned int threads)
 construct thread pool More...
 
template<std::invocable<> Fn>
bool enqueue (Fn &&fn)
 enqueue function More...
 
template<std::invocable<> Fn>
bool operator>> (Fn &&fn)
 alias to enqueue More...
 
template<typename Fn , typename ... Args>
requires std::invocable< Fn, Args... > auto run (Fn &&fn, Args &&... args) -> future< std::invoke_result_t< Fn, Args... > >
 Run a function in the thread_pool. More...
 
void stop ()
 stop thread pool More...
 
 ~thread_pool_t ()
 dtor More...
 
void await_resume ()
 co_await support (nothing returned) More...
 
void await_suspend (std::coroutine_handle<> h)
 co_await support - resumes the coroutine inside of thread_pool More...
 
future< void > join ()
 wait to process all enqueued tasks More...
 
bool is_stopped () const
 test whether is stopped More...
 

Static Public Member Functions

static constexpr bool await_ready () noexcept
 co_await support (never ready) More...
 
static thread_pool_tcurrent ()
 returns current thread pool (in context of managed thread) More...
 

Detailed Description

template<typename CondVar>
class coro::thread_pool_t< CondVar >

thread pool implementation

This is generic thread pool with custom condition variable

Template Parameters
CondVarimplementation of condition variable. It must be compatible with std::condition_variable. Custom condition variable allows implement more featureful managment of idle threads
See also
thread_pool

Definition at line 27 of file thread_pool.h.


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