|
XNetwork 1.7.8
|
Command pattern: tasks are encapsulated as command objects (std::function<void()>) placed in a shared queue; producers (enqueue) are decoupled from executors (worker threads). More...
#include <thread_pool.hpp>
Public Member Functions | |
| thread_pool (size_t num_threads=std::thread::hardware_concurrency()) | |
| ~thread_pool () | |
| thread_pool (const thread_pool &)=delete | |
| thread_pool & | operator= (const thread_pool &)=delete |
| thread_pool (thread_pool &&)=delete | |
| thread_pool & | operator= (thread_pool &&)=delete |
| template<typename F > | |
| auto | enqueue (F &&task) -> std::future< std::invoke_result_t< std::decay_t< F > > > |
Command pattern: tasks are encapsulated as command objects (std::function<void()>) placed in a shared queue; producers (enqueue) are decoupled from executors (worker threads).
enqueue() returns a std::future for result retrieval.
|
inlineexplicit |
| num_threads | Number of worker threads. Defaults to hardware concurrency (min 1). |
|
inline |
|
delete |
|
delete |
|
inline |
Enqueue a callable for execution on the thread pool.
| F | Callable type (invocable, returns T) |
| task | Callable to execute |
|
delete |
|
delete |