Monero
Loading...
Searching...
No Matches
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)
 
void recycle ()
 
unsigned int get_max_concurrency () const
 
 ~threadpool ()
 

Static Public Member Functions

static threadpoolgetInstanceForCompute ()
 
static threadpoolgetInstanceForIO ()
 
static threadpoolgetNewForUnitTests (unsigned max_threads=0)
 

Private Types

typedef struct tools::threadpool::entry entry
 

Private Member Functions

 threadpool (unsigned int max_threads=0)
 
void destroy ()
 
void create (unsigned int max_threads)
 
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

typedef struct tools::threadpool::entry tools::threadpool::entry
private

Constructor & Destructor Documentation

◆ ~threadpool()

tools::threadpool::~threadpool ( )

◆ threadpool()

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

Member Function Documentation

◆ create()

void tools::threadpool::create ( unsigned int max_threads)
private

◆ destroy()

void tools::threadpool::destroy ( )
private

◆ get_max_concurrency()

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

◆ getInstanceForCompute()

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

◆ getInstanceForIO()

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

◆ getNewForUnitTests()

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

◆ recycle()

void tools::threadpool::recycle ( )

◆ 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: