SourceXtractorPlusPlus  0.19
SourceXtractor++, the next generation SExtractor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Prefetcher.h
Go to the documentation of this file.
1 
18 #ifndef _SEIMPLEMENTATION_MEASUREMENT_PREFETCHER_H_
19 #define _SEIMPLEMENTATION_MEASUREMENT_PREFETCHER_H_
20 
21 #include <condition_variable>
26 
27 namespace SourceXtractor {
28 
40 class Prefetcher : public PipelineReceiver<SourceInterface>, public PipelineEmitter<SourceInterface> {
41 public:
42 
48  Prefetcher(const std::shared_ptr<Euclid::ThreadPool>& thread_pool, unsigned max_queue_size);
49 
53  virtual ~Prefetcher();
54 
60  void receiveSource(std::unique_ptr<SourceInterface> source) override;
61 
67  void receiveProcessSignal(const ProcessSourcesEvent& event) override;
68 
76  template<typename Container>
77  void requestProperties(const Container& properties) {
78  for (auto& p : properties) {
79  requestProperty(p);
80  }
81  }
82 
88  void wait();
89 
94  void synchronize();
95 
96 
97 private:
98  struct EventType {
99  enum Type {
101  } m_event_type;
103 
104  explicit EventType(Type type, intptr_t source_addr = -1)
105  : m_event_type(type), m_source_addr(source_addr) {}
106  };
107 
122 
124 
126  std::atomic_bool m_stop;
127 
130 
131  void requestProperty(const PropertyId& property_id);
132  void outputLoop();
133 };
134 
135 } // end of namespace SourceXtractor
136 
137 #endif // _SEIMPLEMENTATION_MEASUREMENT_PREFETCHER_H_
std::unique_ptr< std::thread > m_output_thread
Orchestration thread.
Definition: Prefetcher.h:113
std::map< intptr_t, std::unique_ptr< SourceInterface > > m_finished_sources
Finished sources.
Definition: Prefetcher.h:117
std::deque< EventType > m_received
Queue of type of received events. Used to pass downstream events respecting the received order...
Definition: Prefetcher.h:121
Prefetcher(const std::shared_ptr< Euclid::ThreadPool > &thread_pool, unsigned max_queue_size)
Definition: Prefetcher.cpp:44
std::set< PropertyId > m_prefetch_set
Properties to prefetch.
Definition: Prefetcher.h:111
std::atomic_bool m_stop
Termination condition for the output loop.
Definition: Prefetcher.h:126
Event received by SourceGrouping to request the processing of some of the Sources stored...
Definition: PipelineStage.h:33
void requestProperty(const PropertyId &property_id)
Definition: Prefetcher.cpp:80
std::deque< ProcessSourcesEvent > m_event_queue
Queue of received ProcessSourceEvent, order preserved.
Definition: Prefetcher.h:119
void receiveProcessSignal(const ProcessSourcesEvent &event) override
Definition: Prefetcher.cpp:136
STL class.
std::condition_variable m_new_output
Notifies there is a new source done processing.
Definition: Prefetcher.h:115
void receiveSource(std::unique_ptr< SourceInterface > source) override
Definition: Prefetcher.cpp:54
STL class.
STL class.
STL class.
Identifier used to set and retrieve properties.
Definition: PropertyId.h:40
void requestProperties(const Container &properties)
Definition: Prefetcher.h:77
Euclid::Semaphore m_semaphore
Keep the queue under control.
Definition: Prefetcher.h:129
EventType(Type type, intptr_t source_addr=-1)
Definition: Prefetcher.h:104
std::shared_ptr< Euclid::ThreadPool > m_thread_pool
Pointer to the pool of worker threads.
Definition: Prefetcher.h:109
enum SourceXtractor::Prefetcher::EventType::Type m_event_type