SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
Prefetcher.h
Go to the documentation of this file.
1
17
18#ifndef _SEIMPLEMENTATION_MEASUREMENT_PREFETCHER_H_
19#define _SEIMPLEMENTATION_MEASUREMENT_PREFETCHER_H_
20
21#include <condition_variable>
22#include "AlexandriaKernel/ThreadPool.h"
23#include "AlexandriaKernel/Semaphore.h"
26
27namespace SourceXtractor {
28
40class Prefetcher : public PipelineReceiver<SourceInterface>, public PipelineEmitter<SourceInterface> {
41public:
42
48 Prefetcher(const std::shared_ptr<Euclid::ThreadPool>& thread_pool, unsigned max_queue_size);
49
53 virtual ~Prefetcher();
54
61
67 void receiveProcessSignal(const ProcessSourcesEvent& event) override;
68
76 template<typename Container>
77 void requestProperties(const Container& properties) {
78 for (auto& p : properties) {
80 }
81 }
82
88 void wait();
89
93
94 void synchronize();
95
96
97private:
98 struct EventType {
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_
void requestProperty(const PropertyId &property_id)
void receiveProcessSignal(const ProcessSourcesEvent &event) override
std::deque< ProcessSourcesEvent > m_event_queue
Queue of received ProcessSourceEvent, order preserved.
Definition Prefetcher.h:119
std::shared_ptr< Euclid::ThreadPool > m_thread_pool
Pointer to the pool of worker threads.
Definition Prefetcher.h:109
Prefetcher(const std::shared_ptr< Euclid::ThreadPool > &thread_pool, unsigned max_queue_size)
std::condition_variable m_new_output
Notifies there is a new source done processing.
Definition Prefetcher.h:115
std::deque< EventType > m_received
Queue of type of received events. Used to pass downstream events respecting the received order.
Definition Prefetcher.h:121
void requestProperties(const Container &properties)
Definition Prefetcher.h:77
Euclid::Semaphore m_semaphore
Keep the queue under control.
Definition Prefetcher.h:129
std::set< PropertyId > m_prefetch_set
Properties to prefetch.
Definition Prefetcher.h:111
std::map< intptr_t, std::unique_ptr< SourceInterface > > m_finished_sources
Finished sources.
Definition Prefetcher.h:117
std::unique_ptr< std::thread > m_output_thread
Orchestration thread.
Definition Prefetcher.h:113
void receiveSource(std::unique_ptr< SourceInterface > source) override
std::atomic_bool m_stop
Termination condition for the output loop.
Definition Prefetcher.h:126
Identifier used to set and retrieve properties.
Definition PropertyId.h:40
EventType(Type type, intptr_t source_addr=-1)
Definition Prefetcher.h:104
enum SourceXtractor::Prefetcher::EventType::Type m_event_type
Event received by SourceGrouping to request the processing of some of the Sources stored.