libcoro
1.0
Coroutine support library for C++20
|
thread pool implementation More...
#include <thread_pool.h>
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_t * | current () |
returns current thread pool (in context of managed thread) More... | |
thread pool implementation
This is generic thread pool with custom condition variable
CondVar | implementation of condition variable. It must be compatible with std::condition_variable. Custom condition variable allows implement more featureful managment of idle threads |
Definition at line 27 of file thread_pool.h.