Helios++
Helios software for LiDAR simulations
KDTreeFactoryThreadPool Class Reference

Class implementing a thread pool to deal with multi thread KDTree building process. More...

#include <KDTreeFactoryThreadPool.h>

Inheritance diagram for KDTreeFactoryThreadPool:
Collaboration diagram for KDTreeFactoryThreadPool:

Public Member Functions

 KDTreeFactoryThreadPool (std::size_t const _pool_size)
 KDTree factory thread pool constructor. More...
 
 KDTreeFactoryThreadPool ()
 KDTree factory thread pool constructor which uses concurrent threads supported by the system as the default pool size. More...
 
- Public Member Functions inherited from MDThreadPool< KDTreeBuildType, KDTreeNode *, bool const, vector< Primitive * > &, int const, int const >
 MDThreadPool (std::size_t const _pool_size)
 Multiple data thread pool constructor. More...
 
void run_md_task (Task task, KDTreeBuildType *data)
 Run a task with associated data without considering limit for max pending tasks.
 
bool try_run_md_task (Task task, KDTreeBuildType *data)
 Try to run a task with associated data. If the max limit of pending tasks has not been reached, the task will be run asynchronously and true will be returned once it has been posted to the asynchronous execution service. If the max limit has been reached, then the task will not be posted to the asynchronous execution service and false will be returned. More...
 
void join () override
 Lock until all pending threads have finished.
 
virtual size_t getPendingTasks ()
 Obtain the number of pending tasks to be computed. More...
 
virtual size_t safeGetPendingTasks ()
 Obtain the number of pending tasks to be computed in a thread safe way. It is, with proper handling of concurrent reading. More...
 
virtual void setPendingTasks (size_t const pendingTasks)
 Set the number of pending tasks to be computed. More...
 
virtual void safeSetPendingTasks (size_t const pendingTasks)
 Set the number of pending tasks to be computed in a thread safe way. It is, with proper handling of current writting. More...
 
virtual void subtractPendingTasks (size_t const amount)
 Subtract specified amount of pending tasks. More...
 
virtual void safeSubtractPendingTasks (size_t const amount)
 Subtract pending tasks in a thread safe way. It is, with proper handling of concurrency. More...
 
virtual void increasePendingTasks ()
 Unitary increase the number of pending tasks to be computed.
 
virtual void decreasePendingTasks ()
 Unitary decrease the number of pending tasks to be computed.
 
- Public Member Functions inherited from SimpleThreadPool< TaskArgs ... >
 SimpleThreadPool (std::size_t const _pool_size)
 Simple thread pool constructor. More...
 
void run_task (Task task)
 Run a task when there is an available thread for it.
 
virtual void notifyOne ()
 Notify the conditional variable so if there is a waiting thread it will wake up.
 
- Public Member Functions inherited from ThreadPool
 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

void do_md_task (boost::function< void(KDTreeNode *, bool const, vector< Primitive * > &, int const, int const)> &task, KDTreeBuildType *data) override
 Do a recursive build of KDTree node task. More...
 
- Protected Member Functions inherited from MDThreadPool< KDTreeBuildType, KDTreeNode *, bool const, vector< Primitive * > &, int const, int const >
virtual void wrap_md_task (boost::function< void(TaskArgs ...)> &task, KDTreeBuildType *data)
 Wrap a data task so that pending tasks count can be increased once provided data task has been completed. More...
 
void do_task (boost::function< void(TaskArgs ...)> &task) override
 Throw exception when calling non data do_task. More...
 
virtual void do_md_task (boost::function< void(TaskArgs ...)> &task, KDTreeBuildType *data)=0
 Invoke task with associated data. More...
 
- Protected Member Functions inherited from SimpleThreadPool< TaskArgs ... >
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...
 

Additional Inherited Members

- Protected Attributes inherited from SimpleThreadPool< TaskArgs ... >
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)
 
- Protected Attributes inherited from ThreadPool
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.
 

Detailed Description

Class implementing a thread pool to deal with multi thread KDTree building process.

Author
Alberto M. Esmoris Pena
Version
1.0
See also
ThreadPool
MDThreadPool
MultiThreadKDTreeFactory
KDTreeBuildType

Constructor & Destructor Documentation

◆ KDTreeFactoryThreadPool() [1/2]

KDTreeFactoryThreadPool::KDTreeFactoryThreadPool ( std::size_t const  _pool_size)
inlineexplicit

KDTree factory thread pool constructor.

See also
ThreadPool::pool_size

◆ KDTreeFactoryThreadPool() [2/2]

KDTreeFactoryThreadPool::KDTreeFactoryThreadPool ( )
inlineexplicit

KDTree factory thread pool constructor which uses concurrent threads supported by the system as the default pool size.

See also
KDTreeFactoryThreadPool::KDTreeFactoryThreadPool(std::size_t const)

Member Function Documentation

◆ do_md_task()

void KDTreeFactoryThreadPool::do_md_task ( boost::function< void(KDTreeNode *, bool const, vector< Primitive * > &, int const, int const)> &  task,
KDTreeBuildType data 
)
inlineoverrideprotected

Do a recursive build of KDTree node task.

Parameters
taskRecursive build of KDTree node task
dataIt will be deleted after computing the task
See also
ThreadPool::do_task

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