SourceXtractorPlusPlus  0.10
Please provide a description of the project.
MultithreadedMeasurement.h
Go to the documentation of this file.
1 
17 /*
18  * Multithreadedmeasurement->h
19  *
20  * Created on: May 17, 2018
21  * Author: mschefer
22  */
23 
24 #ifndef _SEIMPLEMENTATION_OUTPUT_MULTITHREADEDMEASUREMENT_H_
25 #define _SEIMPLEMENTATION_OUTPUT_MULTITHREADEDMEASUREMENT_H_
26 
27 #include <atomic>
28 #include <thread>
29 #include <mutex>
30 #include <condition_variable>
31 #include <atomic>
32 
34 
35 namespace SourceXtractor {
36 
38 public:
39 
41  MultithreadedMeasurement(SourceToRowConverter source_to_row, int worker_threads_nb)
42  : m_source_to_row(source_to_row),
43  m_worker_threads_nb(worker_threads_nb),
45  m_group_counter(0),
46  m_input_done(false), m_abort_raised(false) {}
47 
48  void handleMessage(const std::shared_ptr<SourceGroupInterface>& source_group) override;
49 
50  void startThreads() override;
51  void waitForThreads() override;
52 
53 public:
55 
56 private:
57  static void workerThreadStatic(MultithreadedMeasurement* measurement, int id);
58  static void outputThreadStatic(MultithreadedMeasurement* measurement, int id);
59  void workerThreadLoop();
60  void outputThreadLoop();
61 
63 
65 
68 
71 
73  std::atomic_bool m_input_done, m_abort_raised;
77 
81 };
82 
83 }
84 
85 #endif /* _SEIMPLEMENTATION_OUTPUT_MULTITHREADEDMEASUREMENT_H_ */
std::list< std::pair< int, std::shared_ptr< SourceGroupInterface > > > m_input_queue
std::shared_ptr< std::thread > m_output_thread
static void outputThreadStatic(MultithreadedMeasurement *measurement, int id)
MultithreadedMeasurement(SourceToRowConverter source_to_row, int worker_threads_nb)
std::vector< std::shared_ptr< std::thread > > m_worker_threads
STL class.
std::list< std::pair< int, std::shared_ptr< SourceGroupInterface > > > m_output_queue
STL class.
void handleMessage(const std::shared_ptr< SourceGroupInterface > &source_group) override
static void workerThreadStatic(MultithreadedMeasurement *measurement, int id)
The SourceInterface is an abstract "source" that has properties attached to it.