SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
SourceXtractor::MultithreadedMeasurement Class Reference

#include <MultithreadedMeasurement.h>

Inheritance diagram for SourceXtractor::MultithreadedMeasurement:
Inheritance graph
[legend]
Collaboration diagram for SourceXtractor::MultithreadedMeasurement:
Collaboration graph
[legend]

Public Types

using SourceToRowConverter = std::function<Euclid::Table::Row(const SourceInterface&)>
 

Public Member Functions

 MultithreadedMeasurement (SourceToRowConverter source_to_row, const std::shared_ptr< Euclid::ThreadPool > &thread_pool, unsigned max_queue_size)
 
 ~MultithreadedMeasurement () override
 
void receiveSource (std::unique_ptr< SourceGroupInterface > source_group) override
 
void receiveProcessSignal (const ProcessSourcesEvent &event) override
 
void startThreads () override
 
void stopThreads () override
 
void synchronizeThreads () override
 
- Public Member Functions inherited from SourceXtractor::Measurement
 ~Measurement () override=default
 
- Public Member Functions inherited from SourceXtractor::PipelineReceiver< SourceGroupInterface >
virtual ~PipelineReceiver ()=default
 
- Public Member Functions inherited from SourceXtractor::PipelineEmitter< SourceGroupInterface >
 ~PipelineEmitter () override=default
 
void setNextStage (std::shared_ptr< PipelineReceiver< SourceGroupInterface > > next)
 
- Public Member Functions inherited from SourceXtractor::Observable< T >
virtual ~Observable ()=default
 Destructor.
 
virtual void addObserver (std::shared_ptr< Observer< T > > observer)
 Adds an Observer that will be notified when notify Observers is called.
 
virtual void removeObserver (std::shared_ptr< Observer< T > > observer)
 Removes a previously added Observer from the list of Observers to notify.
 

Private Member Functions

void outputThreadLoop ()
 

Static Private Member Functions

static void outputThreadStatic (MultithreadedMeasurement *measurement)
 

Private Attributes

SourceToRowConverter m_source_to_row
 
std::shared_ptr< Euclid::ThreadPoolm_thread_pool
 
std::unique_ptr< std::threadm_output_thread
 
int m_group_counter
 
std::atomic_bool m_input_done
 
std::atomic_bool m_abort_raised
 
std::condition_variable m_new_output
 
std::list< std::pair< int, std::unique_ptr< SourceGroupInterface > > > m_output_queue
 
std::mutex m_output_queue_mutex
 
Euclid::Semaphore m_semaphore
 

Additional Inherited Members

- Protected Member Functions inherited from SourceXtractor::PipelineEmitter< SourceGroupInterface >
void sendSource (std::unique_ptr< SourceGroupInterface > source) const
 
void sendProcessSignal (const ProcessSourcesEvent &event) const
 
- Protected Member Functions inherited from SourceXtractor::Observable< T >
void notifyObservers (const T &message) const
 

Detailed Description

Definition at line 38 of file MultithreadedMeasurement.h.

Member Typedef Documentation

◆ SourceToRowConverter

Definition at line 41 of file MultithreadedMeasurement.h.

Constructor & Destructor Documentation

◆ MultithreadedMeasurement()

SourceXtractor::MultithreadedMeasurement::MultithreadedMeasurement ( SourceToRowConverter source_to_row,
const std::shared_ptr< Euclid::ThreadPool > & thread_pool,
unsigned max_queue_size )
inline

Definition at line 42 of file MultithreadedMeasurement.h.

◆ ~MultithreadedMeasurement()

MultithreadedMeasurement::~MultithreadedMeasurement ( )
override

Definition at line 36 of file MultithreadedMeasurement.cpp.

References std::thread::join(), std::thread::joinable(), and m_output_thread.

Here is the call graph for this function:

Member Function Documentation

◆ outputThreadLoop()

void MultithreadedMeasurement::outputThreadLoop ( )
private

◆ outputThreadStatic()

void MultithreadedMeasurement::outputThreadStatic ( MultithreadedMeasurement * measurement)
staticprivate

Definition at line 103 of file MultithreadedMeasurement.cpp.

References Euclid::Configuration::logger, and std::raise().

Referenced by startThreads().

Here is the call graph for this function:

◆ receiveProcessSignal()

void MultithreadedMeasurement::receiveProcessSignal ( const ProcessSourcesEvent & event)
overridevirtual

Receive a signal to process sources when grouping

Parameters
event

Implements SourceXtractor::PipelineReceiver< SourceGroupInterface >.

Definition at line 141 of file MultithreadedMeasurement.cpp.

References SourceXtractor::PipelineEmitter< SourceGroupInterface >::sendProcessSignal().

Here is the call graph for this function:

◆ receiveSource()

void MultithreadedMeasurement::receiveSource ( std::unique_ptr< SourceGroupInterface > source)
overridevirtual

Receive a source from the previous stage. The receiver owns the object.

Parameters
source

Implements SourceXtractor::PipelineReceiver< SourceGroupInterface >.

Definition at line 76 of file MultithreadedMeasurement.cpp.

References m_group_counter, m_new_output, m_output_queue, m_output_queue_mutex, m_source_to_row, m_thread_pool, std::move(), std::condition_variable::notify_one(), and Euclid::ThreadPool::submit().

Here is the call graph for this function:

◆ startThreads()

void MultithreadedMeasurement::startThreads ( )
overridevirtual

Implements SourceXtractor::Measurement.

Definition at line 42 of file MultithreadedMeasurement.cpp.

References m_output_thread, and outputThreadStatic().

Here is the call graph for this function:

◆ stopThreads()

void MultithreadedMeasurement::stopThreads ( )
overridevirtual

◆ synchronizeThreads()

void MultithreadedMeasurement::synchronizeThreads ( )
overridevirtual

Member Data Documentation

◆ m_abort_raised

std::atomic_bool SourceXtractor::MultithreadedMeasurement::m_abort_raised
private

Definition at line 67 of file MultithreadedMeasurement.h.

◆ m_group_counter

int SourceXtractor::MultithreadedMeasurement::m_group_counter
private

Definition at line 66 of file MultithreadedMeasurement.h.

Referenced by receiveSource().

◆ m_input_done

std::atomic_bool SourceXtractor::MultithreadedMeasurement::m_input_done
private

Definition at line 67 of file MultithreadedMeasurement.h.

Referenced by outputThreadLoop(), and stopThreads().

◆ m_new_output

std::condition_variable SourceXtractor::MultithreadedMeasurement::m_new_output
private

Definition at line 69 of file MultithreadedMeasurement.h.

Referenced by outputThreadLoop(), and receiveSource().

◆ m_output_queue

std::list<std::pair<int, std::unique_ptr<SourceGroupInterface> > > SourceXtractor::MultithreadedMeasurement::m_output_queue
private

Definition at line 70 of file MultithreadedMeasurement.h.

Referenced by outputThreadLoop(), receiveSource(), and synchronizeThreads().

◆ m_output_queue_mutex

std::mutex SourceXtractor::MultithreadedMeasurement::m_output_queue_mutex
private

Definition at line 71 of file MultithreadedMeasurement.h.

Referenced by outputThreadLoop(), receiveSource(), and synchronizeThreads().

◆ m_output_thread

std::unique_ptr<std::thread> SourceXtractor::MultithreadedMeasurement::m_output_thread
private

Definition at line 64 of file MultithreadedMeasurement.h.

Referenced by startThreads(), stopThreads(), and ~MultithreadedMeasurement().

◆ m_semaphore

Euclid::Semaphore SourceXtractor::MultithreadedMeasurement::m_semaphore
private

Definition at line 72 of file MultithreadedMeasurement.h.

◆ m_source_to_row

SourceToRowConverter SourceXtractor::MultithreadedMeasurement::m_source_to_row
private

Definition at line 62 of file MultithreadedMeasurement.h.

Referenced by receiveSource().

◆ m_thread_pool

std::shared_ptr<Euclid::ThreadPool> SourceXtractor::MultithreadedMeasurement::m_thread_pool
private

The documentation for this class was generated from the following files: