Pol  Revision:cb584c9
Pol::threadhelp::TaskThreadPool Class Reference

#include <threadhelp.h>

+ Inheritance diagram for Pol::threadhelp::TaskThreadPool:

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< msgmsg_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
 

Detailed Description

Definition at line 74 of file threadhelp.h.

Member Typedef Documentation

typedef std::function<void()> Pol::threadhelp::TaskThreadPool::msg
private

Definition at line 76 of file threadhelp.h.

Constructor & Destructor Documentation

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().

Member Function Documentation

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 ( )
void Pol::threadhelp::TaskThreadPool::init ( unsigned int  max_count,
const std::string &  name 
)
private
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().

Member Data Documentation

std::atomic<bool> Pol::threadhelp::TaskThreadPool::_done
private

Definition at line 93 of file threadhelp.h.

Referenced by deinit_pool(), and init().

msg_queue Pol::threadhelp::TaskThreadPool::_msg_queue
private

Definition at line 94 of file threadhelp.h.

Referenced by checked_push(), deinit_pool(), init(), and push().

std::vector<std::thread> Pol::threadhelp::TaskThreadPool::_threads
private

Definition at line 95 of file threadhelp.h.

Referenced by deinit_pool(), init(), init_pool(), and size().


The documentation for this class was generated from the following files: