Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

#include <ctpl.h>

Public Member Functions

 thread_pool ()
 
 thread_pool (int nThreads, int queueSize=_ctplThreadPoolLength_)
 
 ~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
 
boost::lockfree::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 48 of file ctpl.h.

Constructor & Destructor Documentation

◆ thread_pool() [1/4]

ctpl::thread_pool::thread_pool ( )
inline

Definition at line 52 of file ctpl.h.

References init().

◆ thread_pool() [2/4]

ctpl::thread_pool::thread_pool ( int  nThreads,
int  queueSize = _ctplThreadPoolLength_ 
)
inline

Definition at line 53 of file ctpl.h.

References init(), and resize().

◆ ~thread_pool()

ctpl::thread_pool::~thread_pool ( )
inline

Definition at line 56 of file ctpl.h.

References stop().

◆ 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 99 of file ctpl.h.

References q.

Referenced by CBLSWorker::Stop(), and stop().

◆ get_thread()

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

Definition at line 65 of file ctpl.h.

References threads.

◆ init()

void ctpl::thread_pool::init ( )
inlineprivate

Definition at line 224 of file ctpl.h.

References isDone, isStop, and nWaiting.

Referenced by thread_pool().

◆ n_idle()

int ctpl::thread_pool::n_idle ( )
inline

Definition at line 64 of file ctpl.h.

References nWaiting.

◆ 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 106 of file ctpl.h.

References q.

◆ push() [1/2]

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

◆ push() [2/2]

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

Definition at line 171 of file ctpl.h.

References cv, mutex, and q.

◆ resize()

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

Definition at line 70 of file ctpl.h.

References cv, flags, isDone, isStop, mutex, set_thread(), and threads.

Referenced by CBLSWorker::Start(), and thread_pool().

◆ set_thread()

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

Definition at line 194 of file ctpl.h.

References cv, flags, isDone, mutex, nWaiting, q, and threads.

Referenced by resize().

◆ size()

int ctpl::thread_pool::size ( )
inline

Definition at line 61 of file ctpl.h.

References threads.

Referenced by RenameThreadPool(), and stop().

◆ stop()

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

Definition at line 121 of file ctpl.h.

References clear_queue(), cv, flags, isDone, isStop, mutex, size(), and threads.

Referenced by CBLSWorker::Stop(), and ~thread_pool().

Member Data Documentation

◆ cv

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

Definition at line 234 of file ctpl.h.

Referenced by push(), resize(), set_thread(), and stop().

◆ flags

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

Definition at line 227 of file ctpl.h.

Referenced by resize(), set_thread(), and stop().

◆ isDone

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

Definition at line 229 of file ctpl.h.

Referenced by init(), resize(), set_thread(), and stop().

◆ isStop

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

Definition at line 230 of file ctpl.h.

Referenced by init(), resize(), and stop().

◆ mutex

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

Definition at line 233 of file ctpl.h.

Referenced by push(), resize(), set_thread(), and stop().

◆ nWaiting

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

Definition at line 231 of file ctpl.h.

Referenced by init(), n_idle(), and set_thread().

◆ q

boost::lockfree::queue<std::function<void(int id)> *> ctpl::thread_pool::q
mutableprivate

Definition at line 228 of file ctpl.h.

Referenced by clear_queue(), pop(), push(), and set_thread().

◆ threads

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

Definition at line 226 of file ctpl.h.

Referenced by get_thread(), resize(), set_thread(), size(), and stop().


The documentation for this class was generated from the following file:
Released under the MIT license