ra4_stats
0341147a0dc35f80f4e12c6003afb76a38e2ed6e
|
#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 5 of file thread_pool.cpp.
References cv_, mutex_, Resize(), stop_at_empty_, stop_thread_now_, tasks_, and threads_.
|
explicit |
ThreadPool::~ThreadPool | ( | ) |
Definition at line 31 of file thread_pool.cpp.
References cv_, mutex_, Size(), stop_at_empty_, and threads_.
|
privatedelete |
|
privatedelete |
|
private |
Definition at line 74 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 abcd_sensitivity::args, cv_, ThreadPool::Queue::mutex_, ThreadPool::Queue::Push(), and tasks_.
Referenced by main().
|
private |
Definition at line 89 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 49 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 45 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(), ThreadPool(), and ~ThreadPool().
|
private |
Definition at line 61 of file thread_pool.hpp.
Referenced by DoTasksFromQueue(), ThreadPool::Queue::Pop(), ThreadPool::Queue::Push(), Resize(), ThreadPool(), and ~ThreadPool().
|
private |
Definition at line 59 of file thread_pool.hpp.
Referenced by ReadyToAct(), ThreadPool(), and ~ThreadPool().
|
private |
Definition at line 58 of file thread_pool.hpp.
Referenced by DoTasksFromQueue(), ReadyToAct(), Resize(), and ThreadPool().
|
private |
Definition at line 56 of file thread_pool.hpp.
Referenced by DoTasksFromQueue(), Push(), ReadyToAct(), and ThreadPool().
|
private |
Definition at line 57 of file thread_pool.hpp.
Referenced by Resize(), Size(), ThreadPool(), and ~ThreadPool().