#include <WorkerThreadPool.hpp>
|
| WorkerThreadPool (unsigned const thread_count=std::thread::hardware_concurrency()) |
|
| ~WorkerThreadPool () |
|
template<typename FunctionType > |
std::future< typename std::invoke_result< FunctionType()>::type > | submit (FunctionType f) |
|
◆ WorkerThreadPool()
WorkerThreadPool::WorkerThreadPool |
( |
unsigned const |
thread_count = std::thread::hardware_concurrency() | ) |
|
|
inline |
84 {
85 try {
86 for (unsigned i = 0; i < thread_count; ++i)
88 } catch (...) {
90 throw;
91 }
92 }
std::atomic_bool _done
Definition: WorkerThreadPool.hpp:128
std::vector< std::thread > _threads
Definition: WorkerThreadPool.hpp:127
void worker_thread()
Definition: WorkerThreadPool.hpp:116
References _done, _threads, and worker_thread().
◆ ~WorkerThreadPool()
WorkerThreadPool::~WorkerThreadPool |
( |
| ) |
|
|
inline |
◆ submit()
template<typename FunctionType >
std::future< typename std::invoke_result< FunctionType()>::type > WorkerThreadPool::submit |
( |
FunctionType |
f | ) |
|
|
inline |
106 {
107 typedef typename std::invoke_result<FunctionType()>::type result_type;
108
109 std::packaged_task<result_type()> task(std::move(f));
110 std::future<result_type> res(task.get_future());
112 return res;
113 }
void push(T &&new_value)
Definition: ThreadSafeQueue.hpp:90
ThreadSafeQueue< FunctionWrapper > _work_queue
Definition: WorkerThreadPool.hpp:129
References _work_queue, and ThreadSafeQueue< T >::push().
◆ worker_thread()
void WorkerThreadPool::worker_thread |
( |
| ) |
|
|
inlineprivate |
◆ _done
std::atomic_bool WorkerThreadPool::_done |
|
private |
◆ _threads
std::vector<std::thread> WorkerThreadPool::_threads |
|
private |
◆ _work_queue
The documentation for this class was generated from the following file: