SourceXtractorPlusPlus
0.19
SourceXtractor++, the next generation SExtractor
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
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/PipelineStage.h
"
26
27
namespace
SourceXtractor {
28
40
class
Prefetcher
:
public
PipelineReceiver
<SourceInterface>,
public
PipelineEmitter
<SourceInterface> {
41
public
:
42
48
Prefetcher
(
const
std::shared_ptr<Euclid::ThreadPool>
& thread_pool,
unsigned
max_queue_size);
49
53
virtual
~Prefetcher
();
54
60
void
receiveSource
(
std::unique_ptr<SourceInterface>
source)
override
;
61
67
void
receiveProcessSignal
(
const
ProcessSourcesEvent
& event)
override
;
68
76
template
<
typename
Container>
77
void
requestProperties
(
const
Container& properties) {
78
for
(
auto
& p : properties) {
79
requestProperty
(p);
80
}
81
}
82
88
void
wait
();
89
94
void
synchronize
();
95
96
97
private
:
98
struct
EventType
{
99
enum
Type
{
100
SOURCE
,
PROCESS_SOURCE
101
}
m_event_type
;
102
intptr_t
m_source_addr
;
103
104
explicit
EventType
(
Type
type,
intptr_t
source_addr = -1)
105
:
m_event_type
(type),
m_source_addr
(source_addr) {}
106
};
107
109
std::shared_ptr<Euclid::ThreadPool>
m_thread_pool
;
111
std::set<PropertyId>
m_prefetch_set
;
113
std::unique_ptr<std::thread>
m_output_thread
;
115
std::condition_variable
m_new_output
;
117
std::map<intptr_t, std::unique_ptr<SourceInterface>
>
m_finished_sources
;
119
std::deque<ProcessSourcesEvent>
m_event_queue
;
121
std::deque<EventType>
m_received
;
122
123
std::mutex
m_queue_mutex
;
124
126
std::atomic_bool
m_stop
;
127
129
Euclid::Semaphore
m_semaphore
;
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_
SourceXtractor::Prefetcher::EventType::SOURCE
Definition:
Prefetcher.h:100
SourceXtractor::Prefetcher::m_output_thread
std::unique_ptr< std::thread > m_output_thread
Orchestration thread.
Definition:
Prefetcher.h:113
ThreadPool.h
SourceXtractor::Prefetcher::EventType::Type
Type
Definition:
Prefetcher.h:99
std::shared_ptr< Euclid::ThreadPool >
SourceXtractor::Prefetcher::m_finished_sources
std::map< intptr_t, std::unique_ptr< SourceInterface > > m_finished_sources
Finished sources.
Definition:
Prefetcher.h:117
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:121
SourceXtractor::Prefetcher::EventType::m_source_addr
intptr_t m_source_addr
Definition:
Prefetcher.h:102
SourceXtractor::Prefetcher::Prefetcher
Prefetcher(const std::shared_ptr< Euclid::ThreadPool > &thread_pool, unsigned max_queue_size)
Definition:
Prefetcher.cpp:44
SourceXtractor::Prefetcher::m_prefetch_set
std::set< PropertyId > m_prefetch_set
Properties to prefetch.
Definition:
Prefetcher.h:111
SourceXtractor::Prefetcher::m_stop
std::atomic_bool m_stop
Termination condition for the output loop.
Definition:
Prefetcher.h:126
SourceXtractor::ProcessSourcesEvent
Event received by SourceGrouping to request the processing of some of the Sources stored...
Definition:
PipelineStage.h:33
PipelineStage.h
SourceXtractor::Prefetcher::requestProperty
void requestProperty(const PropertyId &property_id)
Definition:
Prefetcher.cpp:80
std::condition_variable
SourceXtractor::Prefetcher::m_event_queue
std::deque< ProcessSourcesEvent > m_event_queue
Queue of received ProcessSourceEvent, order preserved.
Definition:
Prefetcher.h:119
SourceXtractor::Prefetcher::receiveProcessSignal
void receiveProcessSignal(const ProcessSourcesEvent &event) override
Definition:
Prefetcher.cpp:136
std::map
STL class.
SourceXtractor::Prefetcher::m_new_output
std::condition_variable m_new_output
Notifies there is a new source done processing.
Definition:
Prefetcher.h:115
std::mutex
SourceXtractor::Prefetcher::EventType::PROCESS_SOURCE
Definition:
Prefetcher.h:100
SourceXtractor::PipelineReceiver
Definition:
PipelineStage.h:46
SourceXtractor::Prefetcher::receiveSource
void receiveSource(std::unique_ptr< SourceInterface > source) override
Definition:
Prefetcher.cpp:54
std::intptr_t
std::deque
STL class.
SourceXtractor::Prefetcher::~Prefetcher
virtual ~Prefetcher()
Definition:
Prefetcher.cpp:49
SourceXtractor::Prefetcher::EventType
Definition:
Prefetcher.h:98
Euclid::Semaphore
SourceXtractor::Prefetcher::outputLoop
void outputLoop()
Definition:
Prefetcher.cpp:85
SourceXtractor::Prefetcher::synchronize
void synchronize()
Definition:
Prefetcher.cpp:151
SourceXtractor::Prefetcher
Definition:
Prefetcher.h:40
SourceInterface.h
std::set
STL class.
std::unique_ptr
STL class.
SourceXtractor::PropertyId
Identifier used to set and retrieve properties.
Definition:
PropertyId.h:40
SourceXtractor::Prefetcher::requestProperties
void requestProperties(const Container &properties)
Definition:
Prefetcher.h:77
SourceXtractor::Prefetcher::wait
void wait()
Definition:
Prefetcher.cpp:146
SourceXtractor::Prefetcher::m_semaphore
Euclid::Semaphore m_semaphore
Keep the queue under control.
Definition:
Prefetcher.h:129
SourceXtractor::Prefetcher::EventType::EventType
EventType(Type type, intptr_t source_addr=-1)
Definition:
Prefetcher.h:104
SourceXtractor::Prefetcher::m_thread_pool
std::shared_ptr< Euclid::ThreadPool > m_thread_pool
Pointer to the pool of worker threads.
Definition:
Prefetcher.h:109
SourceXtractor::Prefetcher::m_queue_mutex
std::mutex m_queue_mutex
Definition:
Prefetcher.h:123
SourceXtractor::PipelineEmitter
Definition:
PipelineStage.h:68
Semaphore.h
SourceXtractor::Prefetcher::EventType::m_event_type
enum SourceXtractor::Prefetcher::EventType::Type m_event_type
Generated by
1.8.5