SourceXtractorPlusPlus  0.13
Please provide a description of the project.
 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>
25 #include "SEUtils/Observable.h"
26 
27 namespace SourceXtractor {
28 
40 class Prefetcher : public Observer<std::shared_ptr<SourceInterface>>,
41  public Observable<std::shared_ptr<SourceInterface>>,
42  public Observer<ProcessSourcesEvent>,
43  public Observable<ProcessSourcesEvent> {
44 public:
45 
52 
56  virtual ~Prefetcher();
57 
63  void handleMessage(const std::shared_ptr<SourceInterface>& message) override;
64 
70  void handleMessage(const ProcessSourcesEvent& message) override;
71 
79  template<typename Container>
80  void requestProperties(Container&& properties) {
81  for (auto& p : properties) {
82  requestProperty(p);
83  }
84  }
85 
91  void wait();
92 
93 private:
94  struct EventType {
95  enum Type {
97  } m_event_type;
99 
100  explicit EventType(Type type, intptr_t source_addr = -1)
101  : m_event_type(type), m_source_addr(source_addr) {}
102  };
103 
118 
120 
122  std::atomic_bool m_stop;
123 
124  void requestProperty(const PropertyId& property_id);
125  void outputLoop();
126 };
127 
128 } // end of namespace SourceXtractor
129 
130 #endif // _SEIMPLEMENTATION_MEASUREMENT_PREFETCHER_H_
std::unique_ptr< std::thread > m_output_thread
Orchestration thread.
Definition: Prefetcher.h:109
std::deque< EventType > m_received
Queue of type of received events. Used to pass downstream events respecting the received order...
Definition: Prefetcher.h:117
std::set< PropertyId > m_prefetch_set
Properties to prefetch.
Definition: Prefetcher.h:107
std::atomic_bool m_stop
Termination condition for the output loop.
Definition: Prefetcher.h:122
Event received by SourceGrouping to request the processing of some of the Sources stored...
void requestProperty(const PropertyId &property_id)
Definition: Prefetcher.cpp:74
void requestProperties(Container &&properties)
Definition: Prefetcher.h:80
std::deque< ProcessSourcesEvent > m_event_queue
Queue of received ProcessSourceEvent, order preserved.
Definition: Prefetcher.h:115
STL class.
std::condition_variable m_new_output
Notifies there is a new source done processing.
Definition: Prefetcher.h:111
Implements the Observer pattern. Notifications will be made using a message of type T...
Definition: Observable.h:51
Prefetcher(const std::shared_ptr< Euclid::ThreadPool > &thread_pool)
Definition: Prefetcher.cpp:44
std::map< intptr_t, std::shared_ptr< SourceInterface > > m_finished_sources
Finished sources.
Definition: Prefetcher.h:113
STL class.
STL class.
STL class.
Identifier used to set and retrieve properties.
Definition: PropertyId.h:40
Observer interface to be used with Observable to implement the Observer pattern.
Definition: Observable.h:38
void handleMessage(const std::shared_ptr< SourceInterface > &message) override
Definition: Prefetcher.cpp:54
EventType(Type type, intptr_t source_addr=-1)
Definition: Prefetcher.h:100
std::shared_ptr< Euclid::ThreadPool > m_thread_pool
Pointer to the pool of worker threads.
Definition: Prefetcher.h:105
enum SourceXtractor::Prefetcher::EventType::Type m_event_type