SourceXtractorPlusPlus
0.13
Please provide a description of the project.
SEImplementation
SEImplementation
Prefetcher
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>
22
#include "
AlexandriaKernel/ThreadPool.h
"
23
#include "
SEFramework/Source/SourceInterface.h
"
24
#include "
SEFramework/Pipeline/SourceGrouping.h
"
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
51
Prefetcher
(
const
std::shared_ptr<Euclid::ThreadPool>
& thread_pool);
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
{
96
SOURCE
,
PROCESS_SOURCE
97
}
m_event_type
;
98
intptr_t
m_source_addr
;
99
100
explicit
EventType
(
Type
type,
intptr_t
source_addr = -1)
101
:
m_event_type
(type),
m_source_addr
(source_addr) {}
102
};
103
105
std::shared_ptr<Euclid::ThreadPool>
m_thread_pool
;
107
std::set<PropertyId>
m_prefetch_set
;
109
std::unique_ptr<std::thread>
m_output_thread
;
111
std::condition_variable
m_new_output
;
113
std::map<intptr_t, std::shared_ptr<SourceInterface>
>
m_finished_sources
;
115
std::deque<ProcessSourcesEvent>
m_event_queue
;
117
std::deque<EventType>
m_received
;
118
119
std::mutex
m_queue_mutex
;
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_
SourceXtractor::Observer
Observer interface to be used with Observable to implement the Observer pattern.
Definition:
Observable.h:38
std::shared_ptr< Euclid::ThreadPool >
SourceXtractor::Prefetcher::m_new_output
std::condition_variable m_new_output
Notifies there is a new source done processing.
Definition:
Prefetcher.h:111
SourceXtractor::ProcessSourcesEvent
Event received by SourceGrouping to request the processing of some of the Sources stored.
Definition:
SourceGrouping.h:71
SourceGrouping.h
SourceXtractor::Prefetcher::m_event_queue
std::deque< ProcessSourcesEvent > m_event_queue
Queue of received ProcessSourceEvent, order preserved.
Definition:
Prefetcher.h:115
SourceInterface.h
SourceXtractor::Prefetcher::EventType::PROCESS_SOURCE
@ PROCESS_SOURCE
Definition:
Prefetcher.h:96
SourceXtractor::Prefetcher::m_queue_mutex
std::mutex m_queue_mutex
Definition:
Prefetcher.h:119
SourceXtractor::Prefetcher::requestProperties
void requestProperties(Container &&properties)
Definition:
Prefetcher.h:80
SourceXtractor::Prefetcher::~Prefetcher
virtual ~Prefetcher()
Definition:
Prefetcher.cpp:49
SourceXtractor::Prefetcher::EventType::SOURCE
@ SOURCE
Definition:
Prefetcher.h:96
SourceXtractor::Prefetcher::m_received
std::deque< EventType > m_received
Queue of type of received events. Used to pass downstream events respecting the received order.
Definition:
Prefetcher.h:117
SourceXtractor::PropertyId
Identifier used to set and retrieve properties.
Definition:
PropertyId.h:40
SourceXtractor::Prefetcher::requestProperty
void requestProperty(const PropertyId &property_id)
Definition:
Prefetcher.cpp:74
SourceXtractor::Prefetcher::m_finished_sources
std::map< intptr_t, std::shared_ptr< SourceInterface > > m_finished_sources
Finished sources.
Definition:
Prefetcher.h:113
SourceXtractor
Definition:
Aperture.h:30
SourceXtractor::Prefetcher::outputLoop
void outputLoop()
Definition:
Prefetcher.cpp:79
SourceXtractor::Prefetcher::m_stop
std::atomic_bool m_stop
Termination condition for the output loop.
Definition:
Prefetcher.h:122
SourceXtractor::Prefetcher::EventType::EventType
EventType(Type type, intptr_t source_addr=-1)
Definition:
Prefetcher.h:100
std::deque
STL class.
std::intptr_t
SourceXtractor::Prefetcher
Definition:
Prefetcher.h:43
SourceXtractor::Prefetcher::EventType::m_event_type
enum SourceXtractor::Prefetcher::EventType::Type m_event_type
std::map
STL class.
Observable.h
SourceXtractor::Prefetcher::wait
void wait()
Definition:
Prefetcher.cpp:139
SourceXtractor::Observable
Implements the Observer pattern. Notifications will be made using a message of type T.
Definition:
Observable.h:51
SourceXtractor::Prefetcher::EventType
Definition:
Prefetcher.h:94
SourceXtractor::Prefetcher::EventType::m_source_addr
intptr_t m_source_addr
Definition:
Prefetcher.h:98
SourceXtractor::Prefetcher::m_output_thread
std::unique_ptr< std::thread > m_output_thread
Orchestration thread.
Definition:
Prefetcher.h:109
std::condition_variable
ThreadPool.h
SourceXtractor::Prefetcher::Prefetcher
Prefetcher(const std::shared_ptr< Euclid::ThreadPool > &thread_pool)
Definition:
Prefetcher.cpp:44
std::mutex
STL class.
SourceXtractor::Prefetcher::handleMessage
void handleMessage(const std::shared_ptr< SourceInterface > &message) override
Definition:
Prefetcher.cpp:54
std::unique_ptr< std::thread >
std::set
STL class.
SourceXtractor::Prefetcher::m_prefetch_set
std::set< PropertyId > m_prefetch_set
Properties to prefetch.
Definition:
Prefetcher.h:107
SourceXtractor::Prefetcher::m_thread_pool
std::shared_ptr< Euclid::ThreadPool > m_thread_pool
Pointer to the pool of worker threads.
Definition:
Prefetcher.h:105
SourceXtractor::Prefetcher::EventType::Type
Type
Definition:
Prefetcher.h:95
Generated by
1.8.20