PIVX Core  5.6.99
P2P Digital Currency
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ctpl::thread_pool Class Reference

#include <ctpl_stl.h>

Collaboration diagram for ctpl::thread_pool:
[legend]

Public Member Functions

 thread_pool ()
 
 thread_pool (int nThreads)
 
 ~thread_pool ()
 
int size ()
 
int n_idle ()
 
std::thread & get_thread (int i)
 
void resize (int nThreads)
 
void clear_queue ()
 
std::function< void(int)> pop ()
 
void stop (bool isWait=false)
 
template<typename F , typename... Rest>
auto push (F &&f, Rest &&... rest) -> std::future< decltype(f(0, rest...))>
 
template<typename F >
auto push (F &&f) -> std::future< decltype(f(0))>
 

Private Member Functions

 thread_pool (const thread_pool &)
 
 thread_pool (thread_pool &&)
 
thread_pooloperator= (const thread_pool &)
 
thread_pooloperator= (thread_pool &&)
 
void set_thread (int i)
 
void init ()
 

Private Attributes

std::vector< std::unique_ptr< std::thread > > threads
 
std::vector< std::shared_ptr< std::atomic< bool > > > flags
 
detail::Queue< std::function< void(int id)> * > q
 
std::atomic< bool > isDone
 
std::atomic< bool > isStop
 
std::atomic< int > nWaiting
 
std::mutex mutex
 
std::condition_variable cv
 

Detailed Description

Definition at line 71 of file ctpl_stl.h.

Constructor & Destructor Documentation

◆ thread_pool() [1/4]

ctpl::thread_pool::thread_pool ( )
inline

Definition at line 75 of file ctpl_stl.h.

Here is the call graph for this function:

◆ thread_pool() [2/4]

ctpl::thread_pool::thread_pool ( int  nThreads)
inlineexplicit

Definition at line 76 of file ctpl_stl.h.

Here is the call graph for this function:

◆ ~thread_pool()

ctpl::thread_pool::~thread_pool ( )
inline

Definition at line 79 of file ctpl_stl.h.

Here is the call graph for this function:

◆ thread_pool() [3/4]

ctpl::thread_pool::thread_pool ( const thread_pool )
private

◆ thread_pool() [4/4]

ctpl::thread_pool::thread_pool ( thread_pool &&  )
private

Member Function Documentation

◆ clear_queue()

void ctpl::thread_pool::clear_queue ( )
inline

Definition at line 122 of file ctpl_stl.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_thread()

std::thread& ctpl::thread_pool::get_thread ( int  i)
inline

Definition at line 88 of file ctpl_stl.h.

◆ init()

void ctpl::thread_pool::init ( )
inlineprivate

Definition at line 236 of file ctpl_stl.h.

Here is the caller graph for this function:

◆ n_idle()

int ctpl::thread_pool::n_idle ( )
inline

Definition at line 87 of file ctpl_stl.h.

◆ operator=() [1/2]

thread_pool& ctpl::thread_pool::operator= ( const thread_pool )
private

◆ operator=() [2/2]

thread_pool& ctpl::thread_pool::operator= ( thread_pool &&  )
private

◆ pop()

std::function<void(int)> ctpl::thread_pool::pop ( )
inline

Definition at line 129 of file ctpl_stl.h.

Here is the call graph for this function:

◆ push() [1/2]

template<typename F >
auto ctpl::thread_pool::push ( F &&  f) -> std::future<decltype(f(0))>
inline

Definition at line 189 of file ctpl_stl.h.

◆ push() [2/2]

template<typename F , typename... Rest>
auto ctpl::thread_pool::push ( F &&  f,
Rest &&...  rest 
) -> std::future<decltype(f(0, rest...))>
inline

Definition at line 173 of file ctpl_stl.h.

Here is the caller graph for this function:

◆ resize()

void ctpl::thread_pool::resize ( int  nThreads)
inline

Definition at line 93 of file ctpl_stl.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_thread()

void ctpl::thread_pool::set_thread ( int  i)
inlineprivate

Definition at line 209 of file ctpl_stl.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

int ctpl::thread_pool::size ( )
inline

Definition at line 84 of file ctpl_stl.h.

Here is the caller graph for this function:

◆ stop()

void ctpl::thread_pool::stop ( bool  isWait = false)
inline

Definition at line 142 of file ctpl_stl.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ cv

std::condition_variable ctpl::thread_pool::cv
private

Definition at line 246 of file ctpl_stl.h.

◆ flags

std::vector<std::shared_ptr<std::atomic<bool> > > ctpl::thread_pool::flags
private

Definition at line 239 of file ctpl_stl.h.

◆ isDone

std::atomic<bool> ctpl::thread_pool::isDone
private

Definition at line 241 of file ctpl_stl.h.

◆ isStop

std::atomic<bool> ctpl::thread_pool::isStop
private

Definition at line 242 of file ctpl_stl.h.

◆ mutex

std::mutex ctpl::thread_pool::mutex
private

Definition at line 245 of file ctpl_stl.h.

◆ nWaiting

std::atomic<int> ctpl::thread_pool::nWaiting
private

Definition at line 243 of file ctpl_stl.h.

◆ q

detail::Queue<std::function<void(int id)> *> ctpl::thread_pool::q
private

Definition at line 240 of file ctpl_stl.h.

◆ threads

std::vector<std::unique_ptr<std::thread> > ctpl::thread_pool::threads
private

Definition at line 238 of file ctpl_stl.h.


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