SourceXtractorPlusPlus  0.19
SourceXtractor++, the next generation SExtractor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
35 
36 namespace SourceXtractor {
37 
39 public:
40 
43  unsigned max_queue_size)
44  : m_source_to_row(source_to_row),
45  m_thread_pool(thread_pool),
46  m_group_counter(0),
47  m_input_done(false), m_abort_raised(false), m_semaphore(max_queue_size) {}
48 
49  ~MultithreadedMeasurement() override;
50 
51  void receiveSource(std::unique_ptr<SourceGroupInterface> source_group) override;
52  void receiveProcessSignal(const ProcessSourcesEvent& event) override;
53 
54  void startThreads() override;
55  void stopThreads() override;
56  void synchronizeThreads() override;
57 
58 private:
59  static void outputThreadStatic(MultithreadedMeasurement* measurement);
60  void outputThreadLoop();
61 
65 
67  std::atomic_bool m_input_done, m_abort_raised;
68 
73 };
74 
75 }
76 
77 #endif /* _SEIMPLEMENTATION_OUTPUT_MULTITHREADEDMEASUREMENT_H_ */
MultithreadedMeasurement(SourceToRowConverter source_to_row, const std::shared_ptr< Euclid::ThreadPool > &thread_pool, unsigned max_queue_size)
Event received by SourceGrouping to request the processing of some of the Sources stored...
Definition: PipelineStage.h:33
std::list< std::pair< int, std::unique_ptr< SourceGroupInterface > > > m_output_queue
void receiveSource(std::unique_ptr< SourceGroupInterface > source_group) override
void receiveProcessSignal(const ProcessSourcesEvent &event) override
STL class.
std::shared_ptr< Euclid::ThreadPool > m_thread_pool
std::unique_ptr< std::thread > m_output_thread
STL class.
static void outputThreadStatic(MultithreadedMeasurement *measurement)