SourceXtractorPlusPlus
0.16
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 "
AlexandriaKernel/Semaphore.h
"
24
#include "
SEFramework/Source/SourceInterface.h
"
25
#include "
SEFramework/Pipeline/SourceGrouping.h
"
26
#include "
SEUtils/Observable.h
"
27
28
namespace
SourceXtractor
{
29
41
class
Prefetcher
:
public
Observer
<std::shared_ptr<SourceInterface>>,
42
public
Observable
<std::shared_ptr<SourceInterface>>,
43
public
Observer
<ProcessSourcesEvent>,
44
public
Observable
<ProcessSourcesEvent> {
45
public
:
46
52
Prefetcher
(
const
std::shared_ptr<Euclid::ThreadPool>
& thread_pool,
unsigned
max_queue_size);
53
57
virtual
~Prefetcher
();
58
64
void
handleMessage
(
const
std::shared_ptr<SourceInterface>
& message)
override
;
65
71
void
handleMessage
(
const
ProcessSourcesEvent
& message)
override
;
72
80
template
<
typename
Container>
81
void
requestProperties
(Container&& properties) {
82
for
(
auto
& p : properties) {
83
requestProperty
(p);
84
}
85
}
86
92
void
wait
();
93
94
private
:
95
struct
EventType
{
96
enum
Type
{
97
SOURCE
,
PROCESS_SOURCE
98
}
m_event_type
;
99
intptr_t
m_source_addr
;
100
101
explicit
EventType
(
Type
type,
intptr_t
source_addr = -1)
102
:
m_event_type
(type),
m_source_addr
(source_addr) {}
103
};
104
106
std::shared_ptr<Euclid::ThreadPool>
m_thread_pool
;
108
std::set<PropertyId>
m_prefetch_set
;
110
std::unique_ptr<std::thread>
m_output_thread
;
112
std::condition_variable
m_new_output
;
114
std::map<intptr_t, std::shared_ptr<SourceInterface>
>
m_finished_sources
;
116
std::deque<ProcessSourcesEvent>
m_event_queue
;
118
std::deque<EventType>
m_received
;
119
120
std::mutex
m_queue_mutex
;
121
123
std::atomic_bool
m_stop
;
124
126
Euclid::Semaphore
m_semaphore
;
127
128
void
requestProperty
(
const
PropertyId
& property_id);
129
void
outputLoop
();
130
};
131
132
}
// end of namespace SourceXtractor
133
134
#endif
// _SEIMPLEMENTATION_MEASUREMENT_PREFETCHER_H_
Observable.h
Semaphore.h
SourceGrouping.h
SourceInterface.h
ThreadPool.h
Euclid::Semaphore
SourceXtractor::Observable
Implements the Observer pattern. Notifications will be made using a message of type T.
Definition:
Observable.h:51
SourceXtractor::Observer
Observer interface to be used with Observable to implement the Observer pattern.
Definition:
Observable.h:38
SourceXtractor::Prefetcher
Definition:
Prefetcher.h:44
SourceXtractor::Prefetcher::requestProperty
void requestProperty(const PropertyId &property_id)
Definition:
Prefetcher.cpp:76
SourceXtractor::Prefetcher::m_event_queue
std::deque< ProcessSourcesEvent > m_event_queue
Queue of received ProcessSourceEvent, order preserved.
Definition:
Prefetcher.h:116
SourceXtractor::Prefetcher::m_thread_pool
std::shared_ptr< Euclid::ThreadPool > m_thread_pool
Pointer to the pool of worker threads.
Definition:
Prefetcher.h:106
SourceXtractor::Prefetcher::m_queue_mutex
std::mutex m_queue_mutex
Definition:
Prefetcher.h:120
SourceXtractor::Prefetcher::outputLoop
void outputLoop()
Definition:
Prefetcher.cpp:81
SourceXtractor::Prefetcher::Prefetcher
Prefetcher(const std::shared_ptr< Euclid::ThreadPool > &thread_pool, unsigned max_queue_size)
Definition:
Prefetcher.cpp:44
SourceXtractor::Prefetcher::m_new_output
std::condition_variable m_new_output
Notifies there is a new source done processing.
Definition:
Prefetcher.h:112
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:118
SourceXtractor::Prefetcher::handleMessage
void handleMessage(const std::shared_ptr< SourceInterface > &message) override
Definition:
Prefetcher.cpp:54
SourceXtractor::Prefetcher::requestProperties
void requestProperties(Container &&properties)
Definition:
Prefetcher.h:81
SourceXtractor::Prefetcher::wait
void wait()
Definition:
Prefetcher.cpp:142
SourceXtractor::Prefetcher::m_semaphore
Euclid::Semaphore m_semaphore
Keep the queue under control.
Definition:
Prefetcher.h:126
SourceXtractor::Prefetcher::m_prefetch_set
std::set< PropertyId > m_prefetch_set
Properties to prefetch.
Definition:
Prefetcher.h:108
SourceXtractor::Prefetcher::m_output_thread
std::unique_ptr< std::thread > m_output_thread
Orchestration thread.
Definition:
Prefetcher.h:110
SourceXtractor::Prefetcher::~Prefetcher
virtual ~Prefetcher()
Definition:
Prefetcher.cpp:49
SourceXtractor::Prefetcher::m_stop
std::atomic_bool m_stop
Termination condition for the output loop.
Definition:
Prefetcher.h:123
SourceXtractor::Prefetcher::m_finished_sources
std::map< intptr_t, std::shared_ptr< SourceInterface > > m_finished_sources
Finished sources.
Definition:
Prefetcher.h:114
SourceXtractor::PropertyId
Identifier used to set and retrieve properties.
Definition:
PropertyId.h:40
std::condition_variable
std::deque
std::intptr_t
std::map
std::mutex
SourceXtractor
Definition:
Aperture.h:30
std::set
std::shared_ptr< Euclid::ThreadPool >
SourceXtractor::Prefetcher::EventType
Definition:
Prefetcher.h:95
SourceXtractor::Prefetcher::EventType::EventType
EventType(Type type, intptr_t source_addr=-1)
Definition:
Prefetcher.h:101
SourceXtractor::Prefetcher::EventType::Type
Type
Definition:
Prefetcher.h:96
SourceXtractor::Prefetcher::EventType::PROCESS_SOURCE
@ PROCESS_SOURCE
Definition:
Prefetcher.h:97
SourceXtractor::Prefetcher::EventType::SOURCE
@ SOURCE
Definition:
Prefetcher.h:97
SourceXtractor::Prefetcher::EventType::m_source_addr
intptr_t m_source_addr
Definition:
Prefetcher.h:99
SourceXtractor::Prefetcher::EventType::m_event_type
enum SourceXtractor::Prefetcher::EventType::Type m_event_type
SourceXtractor::ProcessSourcesEvent
Event received by SourceGrouping to request the processing of some of the Sources stored.
Definition:
SourceGrouping.h:71
std::unique_ptr< std::thread >
Generated by
1.9.1