LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
deeplima::ThreadPool< P > Class Template Reference

#include <deeplima/utils/thread_pool.h>

Inheritance diagram for deeplima::ThreadPool< P >:
deeplima::RnnSequenceClassifier< Model, BaseMatrix, uint32_t > deeplima::RnnSequenceClassifier< eigen_impl::Model, eigen_impl::EmbdVectorizer, uint8_t > deeplima::DependencyParser::GraphDpImpl deeplima::segmentation::impl::SegmentationImpl

Public Member Functions

 ThreadPool (size_t num_threads=0)
void init (size_t num_threads)
size_t get_num_threads () const
virtual ~ThreadPool ()
void stop ()
size_t running ()
void push (void *job)

Protected Member Functions

bool wait_for_new_job (void **job)
 This will wait until a job is available and then job parameter will be set to this available which will be removed from the list.
void wait_for_any_job_notification (const std::function< bool()> fn)
void thread_fn (size_t worker_id)

Protected Attributes

std::vector< std::thread > m_workers
std::atomic< bool > m_stop
std::queue< void * > m_jobs
std::mutex m_mutex
std::condition_variable m_cv
std::mutex m_mutex_notify
std::condition_variable m_cv_notify

Detailed Description

template<class P>
class deeplima::ThreadPool< P >

Definition at line 22 of file thread_pool.h.

Constructor & Destructor Documentation

◆ ThreadPool()

template<class P>
deeplima::ThreadPool< P >::ThreadPool ( size_t num_threads = 0)
inline

Definition at line 26 of file thread_pool.h.

◆ ~ThreadPool()

template<class P>
virtual deeplima::ThreadPool< P >::~ThreadPool ( )
inlinevirtual

Definition at line 52 of file thread_pool.h.

Member Function Documentation

◆ get_num_threads()

template<class P>
size_t deeplima::ThreadPool< P >::get_num_threads ( ) const
inline

Definition at line 47 of file thread_pool.h.

◆ init()

template<class P>
void deeplima::ThreadPool< P >::init ( size_t num_threads)
inline

Definition at line 35 of file thread_pool.h.

◆ push()

template<class P>
void deeplima::ThreadPool< P >::push ( void * job)
inline

Definition at line 94 of file thread_pool.h.

◆ running()

template<class P>
size_t deeplima::ThreadPool< P >::running ( )
inline

Definition at line 89 of file thread_pool.h.

◆ stop()

template<class P>
void deeplima::ThreadPool< P >::stop ( )
inline

Definition at line 59 of file thread_pool.h.

◆ thread_fn()

template<class P>
void deeplima::ThreadPool< P >::thread_fn ( size_t worker_id)
inlineprotected

Definition at line 128 of file thread_pool.h.

◆ wait_for_any_job_notification()

template<class P>
void deeplima::ThreadPool< P >::wait_for_any_job_notification ( const std::function< bool()> fn)
inlineprotected

Definition at line 122 of file thread_pool.h.

◆ wait_for_new_job()

template<class P>
bool deeplima::ThreadPool< P >::wait_for_new_job ( void ** job)
inlineprotected

This will wait until a job is available and then job parameter will be set to this available which will be removed from the list.

Definition at line 106 of file thread_pool.h.

Member Data Documentation

◆ m_cv

template<class P>
std::condition_variable deeplima::ThreadPool< P >::m_cv
protected

Definition at line 169 of file thread_pool.h.

◆ m_cv_notify

template<class P>
std::condition_variable deeplima::ThreadPool< P >::m_cv_notify
protected

Definition at line 172 of file thread_pool.h.

◆ m_jobs

template<class P>
std::queue<void*> deeplima::ThreadPool< P >::m_jobs
protected

Definition at line 167 of file thread_pool.h.

◆ m_mutex

template<class P>
std::mutex deeplima::ThreadPool< P >::m_mutex
protected

Definition at line 168 of file thread_pool.h.

◆ m_mutex_notify

template<class P>
std::mutex deeplima::ThreadPool< P >::m_mutex_notify
protected

Definition at line 171 of file thread_pool.h.

◆ m_stop

template<class P>
std::atomic<bool> deeplima::ThreadPool< P >::m_stop
protected

Definition at line 165 of file thread_pool.h.

◆ m_workers

template<class P>
std::vector<std::thread> deeplima::ThreadPool< P >::m_workers
protected

Definition at line 164 of file thread_pool.h.


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