SourceXtractorPlusPlus
0.17
SourceXtractor++, the next generation SExtractor
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
98
void
synchronize
();
99
100
101
private
:
102
struct
EventType
{
103
enum
Type
{
104
SOURCE
,
PROCESS_SOURCE
105
}
m_event_type
;
106
intptr_t
m_source_addr
;
107
108
explicit
EventType
(
Type
type,
intptr_t
source_addr = -1)
109
:
m_event_type
(type),
m_source_addr
(source_addr) {}
110
};
111
113
std::shared_ptr<Euclid::ThreadPool>
m_thread_pool
;
115
std::set<PropertyId>
m_prefetch_set
;
117
std::unique_ptr<std::thread>
m_output_thread
;
119
std::condition_variable
m_new_output
;
121
std::map<intptr_t, std::shared_ptr<SourceInterface>
>
m_finished_sources
;
123
std::deque<ProcessSourcesEvent>
m_event_queue
;
125
std::deque<EventType>
m_received
;
126
127
std::mutex
m_queue_mutex
;
128
130
std::atomic_bool
m_stop
;
131
133
Euclid::Semaphore
m_semaphore
;
134
135
void
requestProperty
(
const
PropertyId
& property_id);
136
void
outputLoop
();
137
};
138
139
}
// end of namespace SourceXtractor
140
141
#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:123
SourceXtractor::Prefetcher::m_thread_pool
std::shared_ptr< Euclid::ThreadPool > m_thread_pool
Pointer to the pool of worker threads.
Definition:
Prefetcher.h:113
SourceXtractor::Prefetcher::m_queue_mutex
std::mutex m_queue_mutex
Definition:
Prefetcher.h:127
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:119
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:125
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:133
SourceXtractor::Prefetcher::m_prefetch_set
std::set< PropertyId > m_prefetch_set
Properties to prefetch.
Definition:
Prefetcher.h:115
SourceXtractor::Prefetcher::m_output_thread
std::unique_ptr< std::thread > m_output_thread
Orchestration thread.
Definition:
Prefetcher.h:117
SourceXtractor::Prefetcher::synchronize
void synchronize()
Definition:
Prefetcher.cpp:147
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:130
SourceXtractor::Prefetcher::m_finished_sources
std::map< intptr_t, std::shared_ptr< SourceInterface > > m_finished_sources
Finished sources.
Definition:
Prefetcher.h:121
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:102
SourceXtractor::Prefetcher::EventType::EventType
EventType(Type type, intptr_t source_addr=-1)
Definition:
Prefetcher.h:108
SourceXtractor::Prefetcher::EventType::Type
Type
Definition:
Prefetcher.h:103
SourceXtractor::Prefetcher::EventType::PROCESS_SOURCE
@ PROCESS_SOURCE
Definition:
Prefetcher.h:104
SourceXtractor::Prefetcher::EventType::SOURCE
@ SOURCE
Definition:
Prefetcher.h:104
SourceXtractor::Prefetcher::EventType::m_source_addr
intptr_t m_source_addr
Definition:
Prefetcher.h:106
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