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

Public Member Functions

 thread_pool (int nThreads)
 
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
 

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