Pol
Revision:cb584c9
|
#include <threadhelp.h>
Public Member Functions | |
TaskThreadPool () | |
Creates a threadpool of workers. blocks on deconstruction eg: TaskThreadPool workers; for (....) workers.push([&](){dosomework();});. More... | |
TaskThreadPool (const std::string &name) | |
TaskThreadPool (unsigned int max_count, const std::string &name) | |
~TaskThreadPool () | |
std::future< bool > | checked_push (const msg &msg) |
returns a future which will be set once the msg is processed More... | |
void | deinit_pool () |
void | init_pool (unsigned int max_count, const std::string &name) |
void | push (const msg &msg) |
simply fire and forget only the deconstructor ensures the msg to be finished More... | |
size_t | size () const |
Private Types | |
typedef std::function< void()> | msg |
typedef Clib::message_queue< msg > | msg_queue |
Private Member Functions | |
void | init (unsigned int max_count, const std::string &name) |
Private Attributes | |
std::atomic< bool > | _done |
msg_queue | _msg_queue |
std::vector< std::thread > | _threads |
Definition at line 74 of file threadhelp.h.
|
private |
Definition at line 76 of file threadhelp.h.
|
private |
Definition at line 77 of file threadhelp.h.
Pol::threadhelp::TaskThreadPool::TaskThreadPool | ( | ) |
Creates a threadpool of workers. blocks on deconstruction eg: TaskThreadPool workers; for (....) workers.push([&](){dosomework();});.
Definition at line 329 of file threadhelp.cpp.
Pol::threadhelp::TaskThreadPool::TaskThreadPool | ( | const std::string & | name | ) |
Definition at line 331 of file threadhelp.cpp.
References init().
Pol::threadhelp::TaskThreadPool::TaskThreadPool | ( | unsigned int | max_count, |
const std::string & | name | ||
) |
Definition at line 340 of file threadhelp.cpp.
References init().
Pol::threadhelp::TaskThreadPool::~TaskThreadPool | ( | ) |
Definition at line 399 of file threadhelp.cpp.
References deinit_pool().
std::future< bool > Pol::threadhelp::TaskThreadPool::checked_push | ( | const msg & | msg | ) |
returns a future which will be set once the msg is processed
Definition at line 411 of file threadhelp.cpp.
References _msg_queue, and Pol::Clib::message_queue< Message >::push().
Referenced by Pol::Core::write_data().
void Pol::threadhelp::TaskThreadPool::deinit_pool | ( | ) |
Definition at line 386 of file threadhelp.cpp.
References _done, _msg_queue, _threads, Pol::Clib::message_queue< Message >::cancel(), and Pol::Clib::message_queue< Message >::push().
Referenced by Pol::Core::GameState::deinitialize(), and ~TaskThreadPool().
|
private |
Definition at line 346 of file threadhelp.cpp.
References _done, _msg_queue, _threads, ERROR_PRINT, Pol::Clib::force_backtrace(), Pol::Clib::message_queue< Message >::pop_remaining(), and Pol::Clib::message_queue< Message >::pop_wait().
Referenced by init_pool(), and TaskThreadPool().
void Pol::threadhelp::TaskThreadPool::init_pool | ( | unsigned int | max_count, |
const std::string & | name | ||
) |
Definition at line 379 of file threadhelp.cpp.
References _threads, and init().
Referenced by Pol::xmain_inner().
void Pol::threadhelp::TaskThreadPool::push | ( | const msg & | msg | ) |
simply fire and forget only the deconstructor ensures the msg to be finished
Definition at line 405 of file threadhelp.cpp.
References _msg_queue, and Pol::Clib::message_queue< Message >::push().
Referenced by Pol::Core::http_thread(), and Pol::ECompile::parallel_compile().
size_t Pol::threadhelp::TaskThreadPool::size | ( | ) | const |
Definition at line 429 of file threadhelp.cpp.
References _threads.
Referenced by Pol::ECompile::parallel_compile(), and Pol::xmain_inner().
|
private |
Definition at line 93 of file threadhelp.h.
Referenced by deinit_pool(), and init().
|
private |
Definition at line 94 of file threadhelp.h.
Referenced by checked_push(), deinit_pool(), init(), and push().
|
private |
Definition at line 95 of file threadhelp.h.
Referenced by deinit_pool(), init(), init_pool(), and size().