Helios++
Helios software for LiDAR simulations
|
Class representing a thread pool to deal with multi threading tasks. More...
#include <ThreadPool.h>
Public Member Functions | |
thread_pool (std::size_t _pool_size, double deviceAccuracy) | |
Thread pool constructor. More... | |
std::size_t | getPoolSize () |
Obtain the thread pool size. More... | |
template<typename Task > | |
void | run_task (Task task) |
Run a task when there is an available thread for it. | |
void | join () |
Lock until all pending threads have finished. | |
Private Member Functions | |
int | getAvailableResourceSetIndex () |
Obtain the index of an available resource set. More... | |
void | wrap_task (boost::function< void(std::vector< std::vector< double >> &, RandomnessGenerator< double > &, RandomnessGenerator< double > &, NoiseSource< double > &)> &task, int resourceIdx) |
Wrap a task so that available threads count can be increased once provided task has been completed. More... | |
Private Attributes | |
boost::asio::io_service | io_service_ |
Instance of boost input/output service for asynchronous data processing. | |
boost::asio::io_service::work | work_ |
Instance of work 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. | |
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 var to handle tasks dispatching depending on available threads. | |
std::vector< std::vector< double > > * | apMatrices |
RandomnessGenerator< double > * | randGens |
First randomness generators (general purpose), one per thread. | |
RandomnessGenerator< double > * | randGens2 |
Second randomness generators (to substitute old box muller), one per thread. | |
UniformNoiseSource< double > * | intersectionHandlingNoiseSources |
Intersection handling noise sources, one per thread. | |
bool * | resourceSetAvailable |
Array of flags specifying availability of resource sets. More... | |
Class representing a thread pool to deal with multi threading tasks.
|
inlineexplicit |
Thread pool constructor.
deviceAccuracy | Parameter used to handle randomness generation impact on simulation results |
|
inlineprivate |
Obtain the index of an available resource set.
Resource set is composed of: apMatrices[index] randGens[index] randGens2[index]
|
inline |
|
inlineprivate |
Wrap a task so that available threads count can be increased once provided task has been completed.
task | Task to be wrapped |
resourceIdx | Resource index associated with the task. It is necessary to release associated resources so other tasks can use them later |
|
private |
Alpha prime matrices for MarquardtFitter. One per possible thread, to avoid spamming reallocations
|
private |
Array of flags specifying availability of resource sets.
The ith element of this array correspond to the ith resource for any resource set/array
|
private |
Instance of work to report the io service when it has pending tasks.