Helios++
Helios software for LiDAR simulations
|
Abstract class providing implementation of a simple thread pool which assigns tasks to threads. More...
#include <SimpleThreadPool.h>
Public Member Functions | |
SimpleThreadPool (std::size_t const _pool_size) | |
Simple thread pool constructor. More... | |
template<typename Task > | |
void | run_task (Task task) |
Run a task when there is an available thread for it. | |
virtual void | join () |
Lock until all pending threads have finished. | |
virtual void | notifyOne () |
Notify the conditional variable so if there is a waiting thread it will wake up. | |
![]() | |
ThreadPool (std::size_t const _pool_size) | |
Thread pool constructor. More... | |
virtual std::size_t | getPoolSize () const |
Obtain the thread pool size. More... | |
Protected Member Functions | |
virtual void | wrap_task (boost::function< void(TaskArgs ...)> &task) |
Wrap a task so that available threads count can be increased once provided task has been completed. More... | |
virtual void | do_task (boost::function< void(TaskArgs ...)> &task)=0 |
Invoke task with corresponding arguments. More... | |
Protected Attributes | |
std::size_t | available_ |
Number of available threads, those which are not currently performing a task. | |
boost::mutex | mutex_ |
Mutex to handle concurrent tasks. | |
boost::condition_variable | cond_ |
Condition variable to handle tasks dispatching depending on available threads. | |
boost::asio::io_service | io_service_ |
Instance of boost input/output service for asynchronous data processing. | |
std::size_t | pool_size |
Size of thread pool (number of threads) | |
![]() | |
boost::asio::io_service | io_service_ |
Instance of boost input/output service for asynchronous data processing. | |
boost::asio::executor_work_guard< boost::asio::io_service::executor_type > | work_ |
Instance of work guard to report the io service when it has pending tasks. More... | |
std::size_t | pool_size |
Size of thread pool (number of threads) | |
boost::thread_group | threads_ |
Group of threads. | |
Abstract class providing implementation of a simple thread pool which assigns tasks to threads.
TaskArgs | The arguments for the task functor |
|
inlineexplicit |
Simple thread pool constructor.
|
protectedpure virtual |
Invoke task with corresponding arguments.
task | Task to be invoked |
Implemented in ResThreadPool< TaskArgs >, ResThreadPool< std::vector< std::vector< double > > &, RandomnessGenerator< double > &, RandomnessGenerator< double > &, NoiseSource< double > & >, MDThreadPool< MDType, TaskArgs >, and MDThreadPool< KDTreeBuildType, KDTreeNode *, bool const, vector< Primitive * > &, int const, int const >.
|
inlineprotectedvirtual |
Wrap a task so that available threads count can be increased once provided task has been completed.
task | Task to be wrapped |