SourceXtractorPlusPlus  0.16
Please provide a description of the project.
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:
[legend]
Collaboration diagram for SourceXtractor::MultithreadedMeasurement:
[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)
 
virtual ~MultithreadedMeasurement ()
 
void handleMessage (const std::shared_ptr< SourceGroupInterface > &source_group) override
 
void startThreads () override
 
void waitForThreads () override
 
- Public Member Functions inherited from SourceXtractor::Measurement
virtual ~Measurement ()=default
 
- Public Member Functions inherited from SourceXtractor::Observer< std::shared_ptr< SourceGroupInterface > >
virtual ~Observer ()=default
 
- Public Member Functions inherited from SourceXtractor::Observable< std::shared_ptr< SourceGroupInterface > >
virtual ~Observable ()=default
 Destructor. More...
 
virtual void addObserver (std::shared_ptr< Observer< std::shared_ptr< SourceGroupInterface > >> observer)
 Adds an Observer that will be notified when notify Observers is called. More...
 
virtual void removeObserver (std::shared_ptr< Observer< std::shared_ptr< SourceGroupInterface > >> observer)
 Removes a previously added Observer from the list of Observers to notify. More...
 

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::shared_ptr< SourceGroupInterface > > > m_output_queue
 
std::mutex m_output_queue_mutex
 
Euclid::Semaphore m_semaphore
 

Additional Inherited Members

- Protected Member Functions inherited from SourceXtractor::Observable< std::shared_ptr< SourceGroupInterface > >
void notifyObservers (const std::shared_ptr< SourceGroupInterface > &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 ( )
virtual

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

◆ handleMessage()

void MultithreadedMeasurement::handleMessage ( const std::shared_ptr< SourceGroupInterface > &  source_group)
overridevirtual

Implements SourceXtractor::Observer< std::shared_ptr< SourceGroupInterface > >.

Definition at line 54 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::condition_variable::notify_one(), and Euclid::ThreadPool::submit().

Here is the call graph for this function:

◆ outputThreadLoop()

void MultithreadedMeasurement::outputThreadLoop ( )
private

◆ outputThreadStatic()

void MultithreadedMeasurement::outputThreadStatic ( MultithreadedMeasurement measurement)
staticprivate

Definition at line 77 of file MultithreadedMeasurement.cpp.

References e, SourceXtractor::logger, m_abort_raised, and outputThreadLoop().

Referenced by startThreads().

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:

◆ waitForThreads()

void MultithreadedMeasurement::waitForThreads ( )
overridevirtual

Implements SourceXtractor::Measurement.

Definition at line 46 of file MultithreadedMeasurement.cpp.

References Euclid::ThreadPool::block(), std::thread::join(), SourceXtractor::logger, m_input_done, m_output_thread, and m_thread_pool.

Here is the call graph for this function:

Member Data Documentation

◆ m_abort_raised

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

Definition at line 65 of file MultithreadedMeasurement.h.

Referenced by outputThreadStatic().

◆ m_group_counter

int SourceXtractor::MultithreadedMeasurement::m_group_counter
private

Definition at line 64 of file MultithreadedMeasurement.h.

Referenced by handleMessage().

◆ m_input_done

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

Definition at line 65 of file MultithreadedMeasurement.h.

Referenced by outputThreadLoop(), and waitForThreads().

◆ m_new_output

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

Definition at line 67 of file MultithreadedMeasurement.h.

Referenced by handleMessage(), and outputThreadLoop().

◆ m_output_queue

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

Definition at line 68 of file MultithreadedMeasurement.h.

Referenced by handleMessage(), and outputThreadLoop().

◆ m_output_queue_mutex

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

Definition at line 69 of file MultithreadedMeasurement.h.

Referenced by handleMessage(), and outputThreadLoop().

◆ m_output_thread

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

◆ m_semaphore

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

Definition at line 70 of file MultithreadedMeasurement.h.

◆ m_source_to_row

SourceToRowConverter SourceXtractor::MultithreadedMeasurement::m_source_to_row
private

Definition at line 60 of file MultithreadedMeasurement.h.

Referenced by handleMessage().

◆ m_thread_pool

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

Definition at line 61 of file MultithreadedMeasurement.h.

Referenced by handleMessage(), outputThreadLoop(), and waitForThreads().


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