3 #include <ResThreadPool.h>
4 #include <scanner/detector/PulseThreadPoolInterface.h>
5 #include <noise/RandomnessGenerator.h>
6 #include <noise/UniformNoiseSource.h>
7 #include <TimeWatcher.h>
16 std::vector<std::vector<double>>&,
17 RandomnessGenerator<double>&,
18 RandomnessGenerator<double>&,
80 std::size_t
const _pool_size,
81 double const deviceAccuracy,
85 std::vector<std::vector<double>>&,
96 intersectionHandlingNoiseSources =
100 for (std::size_t i = 0; i < this->
pool_size; ++i){
107 *DEFAULT_RG, 0.0, 1.0
129 std::vector<std::vector<double>>&,
144 std::vector<std::vector<double>>&,
157 std::vector<std::vector<double>>&,
173 boost::function<
void(
174 std::vector<std::vector<double>>&,
179 int const resourceIdx
194 boost::function<
void(
195 std::vector<std::vector<double>>&,
200 int const resourceIdx
207 catch (
const std::exception &e) {
208 std::stringstream ss;
209 ss <<
"PulseThreadPool::wrap_res_task EXCEPTION: " << e.what();
210 logging::WARN(ss.str());
214 boost::unique_lock<boost::mutex> lock(this->
mutex_);
219 this->
cond_.notify_one();
Class to handle a noise source.
Definition: NoiseSource.h:17
Pulse task interface.
Definition: PulseTask.h:13
Interface for thread pools supporting pulse tasks.
Definition: PulseThreadPoolInterface.h:18
Class implementing a thread pool to deal with pulse tasks.
Definition: PulseThreadPool.h:22
TimeWatcher idleTimer
Time watcher to count the amount of idle time.
Definition: PulseThreadPool.h:63
void wrap_res_task(boost::function< void(std::vector< std::vector< double >> &, RandomnessGenerator< double > &, RandomnessGenerator< double > &, NoiseSource< double > &)> &task, int const resourceIdx) override
Override task wrapping so when the full thread group is used the time at which first occupied thread ...
Definition: PulseThreadPool.h:193
std::vector< std::vector< double > > * apMatrices
Definition: PulseThreadPool.h:34
bool dynamic
Specify whether the pulse thread pool uses a dynamic chunk size strategy (true) or a static one (fals...
Definition: PulseThreadPool.h:68
void run_pulse_task(TaskDropper< PulseTask, PulseThreadPoolInterface, std::vector< std::vector< double >> &, RandomnessGenerator< double > &, RandomnessGenerator< double > &, NoiseSource< double > & > &dropper) override
Definition: PulseThreadPool.h:125
PulseThreadPool(std::size_t const _pool_size, double const deviceAccuracy, bool const dynamic)
Pulse thread pool constructor.
Definition: PulseThreadPool.h:79
virtual bool isDynamic() const
Check if the pulse thread pool is operating on dynamic mode (true) or not (false)
Definition: PulseThreadPool.h:228
void do_res_task(boost::function< void(std::vector< std::vector< double >> &, RandomnessGenerator< double > &, RandomnessGenerator< double > &, NoiseSource< double > &)> &task, int const resourceIdx) override
Do a pulse task.
Definition: PulseThreadPool.h:172
UniformNoiseSource< double > * intersectionHandlingNoiseSources
Intersection handling noise sources, one per thread.
Definition: PulseThreadPool.h:48
RandomnessGenerator< double > * randGens
First randomness generators (general purpose), one per thread.
Definition: PulseThreadPool.h:39
bool try_run_pulse_task(TaskDropper< PulseTask, PulseThreadPoolInterface, std::vector< std::vector< double >> &, RandomnessGenerator< double > &, RandomnessGenerator< double > &, NoiseSource< double > & > &dropper) override
Definition: PulseThreadPool.h:140
RandomnessGenerator< double > * randGens2
Second randomness generators (to substitute old box muller), one per thread.
Definition: PulseThreadPool.h:44
void join() override
Definition: PulseThreadPool.h:155
void computeUniformRealDistribution(RealType lowerBound, RealType upperBound)
Compute a uniform real distribution using the specified real data type.
Definition: RandomnessGenerator.h:354
void computeNormalDistribution(RealType mean, RealType stdev)
Compute a normal distribution using the specified real data type.
Definition: RandomnessGenerator.h:400
Abstract class extending basic thread pool implementation to provide a basis layer to handle thread a...
Definition: ResThreadPool.h:13
void run_res_task(Task task)
Run a task with associated resources when there is an available thread for it.
Definition: ResThreadPool.h:67
bool try_run_res_task(Task task)
Run a task with associated resources. If there is not even a single available thread,...
Definition: ResThreadPool.h:105
bool * resourceSetAvailable
Array of flags specifying availability of resource sets.
Definition: ResThreadPool.h:21
std::size_t pool_size
Size of thread pool (number of threads)
Definition: ThreadPool.h:47
boost::mutex mutex_
Mutex to handle concurrent tasks.
Definition: SimpleThreadPool.h:26
boost::condition_variable cond_
Condition variable to handle tasks dispatching depending on available threads.
Definition: SimpleThreadPool.h:31
std::size_t available_
Number of available threads, those which are not currently performing a task.
Definition: SimpleThreadPool.h:22
Class which handles tasks dropping. It is, executing and then removing each task when dropping.
Definition: TaskDropper.h:22
A time watcher can be used to perform and report time measures.
Definition: TimeWatcher.h:13
void startIfNull()
Start the time watcher but only if it has not been started before. Previous start might come either f...
Definition: TimeWatcher.cpp:22