Helios++
Helios software for LiDAR simulations
PulseWarehouseThreadPool Class Reference

Class implementing a warehouse thread pool to deal with pulse tasks. More...

#include <PulseWarehouseThreadPool.h>

Inheritance diagram for PulseWarehouseThreadPool:
Collaboration diagram for PulseWarehouseThreadPool:

Public Member Functions

 PulseWarehouseThreadPool (std::size_t const _pool_size, double const deviceAccuracy, std::size_t const maxTasks=256)
 Pulse warehouse thread pool constructor. More...
 
void run_pulse_task (TaskDropper< PulseTask, PulseThreadPoolInterface, std::vector< std::vector< double >> &, RandomnessGenerator< double > &, RandomnessGenerator< double > &, NoiseSource< double > & > &dropper) override
 
bool try_run_pulse_task (TaskDropper< PulseTask, PulseThreadPoolInterface, std::vector< std::vector< double >> &, RandomnessGenerator< double > &, RandomnessGenerator< double > &, NoiseSource< double > & > &dropper) override
 
void join () override
 
- Public Member Functions inherited from WarehouseThreadPool< PulseTaskDropper >
virtual bool post (shared_ptr< PulseTaskDropper > task)
 Expose the warehouse post method. More...
 
virtual bool post (vector< shared_ptr< PulseTaskDropper >> &tasks)
 Expose the warehouse post method. More...
 
virtual shared_ptr< PulseTaskDropperget ()
 Expose the warehouse get method. More...
 
virtual void notify ()
 Expose the warehouse notify method. More...
 
virtual void notifyAll ()
 Expose the warehouse notify all method. More...
 
virtual void start ()
 Start the warehouse thread pool. More...
 
virtual void finish ()
 Finish the warehouse thread pool in a proper way. It is, allowing all tasks to finish properly and emptying the warehouse. More...
 
- 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 doTask (size_t const tid, shared_ptr< PulseTaskDropper > task) override
 Thread execute given task using its associated resources. It is, its apMatrix, its randomness generators and its noise source. More...
 
- Protected Member Functions inherited from WarehouseThreadPool< PulseTaskDropper >
 WarehouseThreadPool (std::size_t const _pool_size, std::size_t const maxTasks=256)
 Warehouse thread pool constructor. More...
 
virtual void _start (size_t const tid)
 Start a thread. More...
 
virtual void finalJoin ()
 Lock until all pending tasks have been finished. If it is not called after finish, it will lead to an eternal waiting. More...
 

Protected Attributes

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.
 
- Protected Attributes inherited from WarehouseThreadPool< PulseTaskDropper >
TaskWarehouse< PulseTaskDropperwarehouse
 The task warehouse used to handle tasks.
 
bool working
 True if thread pool is working, false if it is already finished. More...
 
int workersCount
 Count how many active workers there are. It is used for final join.
 
int pendingCount
 Count how many workers with pending tasks there are. It is used for join (not final join). It can also be read as working count (not workers count) because it counts how many working threads there are.
 
boost::mutex mtx
 Mutex to handle concurrent access to workers count.
 
boost::condition_variable condvar
 Conditional variable to handle concurrent access to workers count.
 
boost::mutex joinMtx
 Mutex to handle join until warehouse is empty (not the final join) More...
 
boost::condition_variable joinCondvar
 Conditional variable to handle join until warehouse is empty (not the final join) More...
 
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 warehouse thread pool to deal with pulse tasks.

Author
Alberto M. Esmoris Pena
Version
1.0
See also
WarehouseThreadPool

Constructor & Destructor Documentation

◆ PulseWarehouseThreadPool()

PulseWarehouseThreadPool::PulseWarehouseThreadPool ( std::size_t const  _pool_size,
double const  deviceAccuracy,
std::size_t const  maxTasks = 256 
)
inlineexplicit

Pulse warehouse thread pool constructor.

See also
ThreadPool::pool_size
Parameters
deviceAccuracyParameter used to handle randomness generation impact on simulation results

Member Function Documentation

◆ doTask()

void PulseWarehouseThreadPool::doTask ( size_t const  tid,
shared_ptr< PulseTaskDropper task 
)
inlineoverrideprotectedvirtual

Thread execute given task using its associated resources. It is, its apMatrix, its randomness generators and its noise source.

See also
WarehouseThreadPool::doTask
PulseWarehouseThreadPool::apMatrices
PulseWarehouseThreadPool::randGens
PulseWarehouseThreadPool::randGens2
PulseWarehouseThreadPool::intersectionHandlingNoiseSources

Reimplemented from WarehouseThreadPool< PulseTaskDropper >.

◆ join()

void PulseWarehouseThreadPool::join ( )
inlineoverridevirtual

◆ run_pulse_task()

void PulseWarehouseThreadPool::run_pulse_task ( TaskDropper< PulseTask, PulseThreadPoolInterface, std::vector< std::vector< double >> &, RandomnessGenerator< double > &, RandomnessGenerator< double > &, NoiseSource< double > & > &  dropper)
inlineoverridevirtual

◆ try_run_pulse_task()

bool PulseWarehouseThreadPool::try_run_pulse_task ( TaskDropper< PulseTask, PulseThreadPoolInterface, std::vector< std::vector< double >> &, RandomnessGenerator< double > &, RandomnessGenerator< double > &, NoiseSource< double > & > &  dropper)
inlineoverridevirtual

Member Data Documentation

◆ apMatrices

std::vector<std::vector<double> >* PulseWarehouseThreadPool::apMatrices
protected

Alpha prime matrices for MarquardtFitter. One per thread, to avoid spamming reallocations


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