Public Member Functions | Private Member Functions | Private Attributes | List of all members
ctpl::thread_pool Class Reference

#include <ctpl.h>

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 48 of file ctpl.h.

Constructor & Destructor Documentation

◆ thread_pool() [1/8]

ctpl::thread_pool::thread_pool ( )
inline

Definition at line 52 of file ctpl.h.

◆ thread_pool() [2/8]

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

Definition at line 53 of file ctpl.h.

◆ ~thread_pool() [1/2]

ctpl::thread_pool::~thread_pool ( )
inline

Definition at line 56 of file ctpl.h.

◆ thread_pool() [3/8]

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

◆ thread_pool() [4/8]

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

◆ thread_pool() [5/8]

ctpl::thread_pool::thread_pool ( )
inline

Definition at line 91 of file ctpl_stl.h.

◆ thread_pool() [6/8]

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

Definition at line 92 of file ctpl_stl.h.

◆ ~thread_pool() [2/2]

ctpl::thread_pool::~thread_pool ( )
inline

Definition at line 95 of file ctpl_stl.h.

◆ thread_pool() [7/8]

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

◆ thread_pool() [8/8]

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

Member Function Documentation

◆ clear_queue() [1/2]

void ctpl::thread_pool::clear_queue ( )
inline

Definition at line 99 of file ctpl.h.

◆ clear_queue() [2/2]

void ctpl::thread_pool::clear_queue ( )
inline

Definition at line 138 of file ctpl_stl.h.

◆ get_thread() [1/2]

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

Definition at line 65 of file ctpl.h.

◆ get_thread() [2/2]

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

Definition at line 104 of file ctpl_stl.h.

◆ init() [1/2]

void ctpl::thread_pool::init ( )
inlineprivate

Definition at line 241 of file ctpl.h.

◆ init() [2/2]

void ctpl::thread_pool::init ( )
inlineprivate

Definition at line 252 of file ctpl_stl.h.

◆ n_idle() [1/2]

int ctpl::thread_pool::n_idle ( )
inline

Definition at line 64 of file ctpl.h.

◆ n_idle() [2/2]

int ctpl::thread_pool::n_idle ( )
inline

Definition at line 103 of file ctpl_stl.h.

◆ operator=() [1/4]

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

◆ operator=() [2/4]

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

◆ operator=() [3/4]

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

◆ operator=() [4/4]

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

◆ pop() [1/2]

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

Definition at line 106 of file ctpl.h.

◆ pop() [2/2]

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

Definition at line 145 of file ctpl_stl.h.

◆ push() [1/4]

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

Definition at line 188 of file ctpl.h.

◆ push() [2/4]

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

Definition at line 205 of file ctpl_stl.h.

◆ push() [3/4]

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

Definition at line 152 of file ctpl.h.

◆ push() [4/4]

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

Definition at line 189 of file ctpl_stl.h.

◆ resize() [1/2]

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

Definition at line 70 of file ctpl.h.

◆ resize() [2/2]

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

Definition at line 109 of file ctpl_stl.h.

◆ set_thread() [1/2]

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

Definition at line 211 of file ctpl.h.

◆ set_thread() [2/2]

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

Definition at line 225 of file ctpl_stl.h.

◆ size() [1/2]

int ctpl::thread_pool::size ( )
inline

Definition at line 61 of file ctpl.h.

◆ size() [2/2]

int ctpl::thread_pool::size ( )
inline

Definition at line 100 of file ctpl_stl.h.

◆ stop() [1/2]

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

Definition at line 121 of file ctpl.h.

◆ stop() [2/2]

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

Definition at line 158 of file ctpl_stl.h.

Member Data Documentation

◆ cv

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

Definition at line 251 of file ctpl.h.

◆ flags

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

Definition at line 244 of file ctpl.h.

◆ isDone

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

Definition at line 246 of file ctpl.h.

◆ isStop

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

Definition at line 247 of file ctpl.h.

◆ mutex

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

Definition at line 250 of file ctpl.h.

◆ nWaiting

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

Definition at line 248 of file ctpl.h.

◆ q [1/2]

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

Definition at line 245 of file ctpl.h.

◆ q [2/2]

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

Definition at line 256 of file ctpl_stl.h.

◆ threads

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

Definition at line 243 of file ctpl.h.


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


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:26