ra4_draw
4bd0201e3d922d42bd545d4b045ed44db33454a4
|
#include <thread_pool.hpp>
Classes | |
class | Queue |
Public Member Functions | |
ThreadPool () | |
ThreadPool (std::size_t num_threads) | |
~ThreadPool () | |
std::size_t | Size () const |
void | Resize (size_t num_threads) |
template<typename FuncType , typename... ArgTypes> | |
auto | Push (FuncType &&func, ArgTypes &&...args) -> std::future< decltype(func(args...))> |
Private Member Functions | |
ThreadPool (const ThreadPool &)=delete | |
ThreadPool & | operator= (const ThreadPool &)=delete |
ThreadPool (ThreadPool &&)=delete | |
ThreadPool & | operator= (ThreadPool &&)=delete |
void | DoTasksFromQueue (size_t ithread) |
bool | ReadyToAct (size_t ithread, std::unique_ptr< std::function< void()> > &task) |
Private Attributes | |
Queue | tasks_ |
std::vector< std::unique_ptr< std::thread > > | threads_ |
std::vector< std::shared_ptr< std::atomic< bool > > > | stop_thread_now_ |
std::atomic< bool > | stop_at_empty_ |
std::mutex | mutex_ |
std::condition_variable | cv_ |
Definition at line 15 of file thread_pool.hpp.
ThreadPool::ThreadPool | ( | ) |
Definition at line 7 of file thread_pool.cpp.
References Resize().
|
explicit |
Definition at line 24 of file thread_pool.cpp.
References Resize().
ThreadPool::~ThreadPool | ( | ) |
Definition at line 35 of file thread_pool.cpp.
References cv_, mutex_, Size(), stop_at_empty_, and threads_.
|
privatedelete |
|
privatedelete |
|
private |
Definition at line 78 of file thread_pool.cpp.
References cv_, mutex_, ThreadPool::Queue::Pop(), ReadyToAct(), stop_thread_now_, and tasks_.
Referenced by Resize().
|
privatedelete |
|
privatedelete |
auto ThreadPool::Push | ( | FuncType && | func, |
ArgTypes &&... | args | ||
) | -> std::future<decltype(func(args...))> |
Definition at line 66 of file thread_pool.hpp.
References compile::args, cv_, ThreadPool::Queue::mutex_, ThreadPool::Queue::Push(), and tasks_.
|
private |
Definition at line 93 of file thread_pool.cpp.
References ThreadPool::Queue::Pop(), stop_at_empty_, stop_thread_now_, and tasks_.
Referenced by DoTasksFromQueue().
void ThreadPool::Resize | ( | size_t | num_threads | ) |
Definition at line 53 of file thread_pool.cpp.
References cv_, DoTasksFromQueue(), mutex_, Size(), stop_thread_now_, and threads_.
Referenced by ThreadPool().
size_t ThreadPool::Size | ( | ) | const |
Definition at line 49 of file thread_pool.cpp.
References threads_.
Referenced by Resize(), and ~ThreadPool().
|
private |
Definition at line 62 of file thread_pool.hpp.
Referenced by DoTasksFromQueue(), Push(), Resize(), and ~ThreadPool().
|
private |
Definition at line 61 of file thread_pool.hpp.
Referenced by DoTasksFromQueue(), ThreadPool::Queue::Pop(), ThreadPool::Queue::Push(), Resize(), and ~ThreadPool().
|
private |
Definition at line 59 of file thread_pool.hpp.
Referenced by ReadyToAct(), and ~ThreadPool().
|
private |
Definition at line 58 of file thread_pool.hpp.
Referenced by DoTasksFromQueue(), ReadyToAct(), and Resize().
|
private |
Definition at line 56 of file thread_pool.hpp.
Referenced by DoTasksFromQueue(), Push(), and ReadyToAct().
|
private |
Definition at line 57 of file thread_pool.hpp.
Referenced by Resize(), Size(), and ~ThreadPool().