Electroneum
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
tools::threadpool Class Reference

A global thread pool. More...

#include <threadpool.h>

Classes

struct  entry
 
class  waiter
 

Public Member Functions

void submit (waiter *waiter, std::function< void()> f, bool leaf=false)
 
unsigned int get_max_concurrency () const
 
 ~threadpool ()
 

Static Public Member Functions

static threadpoolgetInstance ()
 
static threadpoolgetNewForUnitTests (unsigned max_threads=0)
 

Private Types

typedef struct tools::threadpool::entry entry
 

Private Member Functions

 threadpool (unsigned int max_threads=0)
 
void run (bool flush=false)
 

Private Attributes

std::deque< entryqueue
 
boost::condition_variable has_work
 
boost::mutex mutex
 
std::vector< boost::thread > threads
 
unsigned int active
 
unsigned int max
 
bool running
 

Detailed Description

A global thread pool.

Member Typedef Documentation

◆ entry

Constructor & Destructor Documentation

◆ ~threadpool()

tools::threadpool::~threadpool ( )

◆ threadpool()

tools::threadpool::threadpool ( unsigned int  max_threads = 0)
private

Member Function Documentation

◆ get_max_concurrency()

unsigned int tools::threadpool::get_max_concurrency ( ) const

◆ getInstance()

static threadpool& tools::threadpool::getInstance ( )
inlinestatic

◆ getNewForUnitTests()

static threadpool* tools::threadpool::getNewForUnitTests ( unsigned  max_threads = 0)
inlinestatic

◆ run()

void tools::threadpool::run ( bool  flush = false)
private

◆ submit()

void tools::threadpool::submit ( waiter waiter,
std::function< void()>  f,
bool  leaf = false 
)

Member Data Documentation

◆ active

unsigned int tools::threadpool::active
private

◆ has_work

boost::condition_variable tools::threadpool::has_work
private

◆ max

unsigned int tools::threadpool::max
private

◆ mutex

boost::mutex tools::threadpool::mutex
private

◆ queue

std::deque<entry> tools::threadpool::queue
private

◆ running

bool tools::threadpool::running
private

◆ threads

std::vector<boost::thread> tools::threadpool::threads
private

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