Ardour  9.0-pre0-582-g084a23a80d
AudioGrapher::Threader< T > Class Template Reference

Class for distributing processing across several threads. More...

#include <threader.h>

Inheritance diagram for AudioGrapher::Threader< T >:
[legend]

Public Member Functions

 Threader (Glib::ThreadPool &thread_pool, long wait_timeout_milliseconds=500)
 
virtual ~Threader ()
 
void add_output (typename Source< T >::SinkPtr output)
 Adds output
RT safe. More...
 
void clear_outputs ()
 Clears outputs
RT safe. More...
 
void remove_output (typename Source< T >::SinkPtr output)
 Removes a specific output
RT safe. More...
 
void process (ProcessContext< T > const &c)
 Processes context concurrently by scheduling each output separately to the given thread pool. More...
 
- Public Member Functions inherited from AudioGrapher::Source< DefaultSampleType >
virtual ~Source ()
 
virtual void add_output (SinkPtr output)=0
 Adds an output to this source. All data generated is forwarded to output. More...
 
virtual void remove_output (SinkPtr output)=0
 Removes a specific output from this source. More...
 
- Public Member Functions inherited from AudioGrapher::Sink< DefaultSampleType >
virtual ~Sink ()
 
virtual void process (ProcessContext< DefaultSampleType > const &context)=0
 
virtual void process (ProcessContext< DefaultSampleType > &context)
 

Private Types

typedef std::vector< typename Source< T >::SinkPtrOutputVec
 

Private Member Functions

void wait ()
 
void process_output (ProcessContext< T > const &c, unsigned int output)
 

Private Attributes

OutputVec outputs
 
Glib::ThreadPool & thread_pool
 
Glib::Threads::Mutex wait_mutex
 
Glib::Threads::Cond wait_cond
 
std::atomic< int > readers
 
long wait_timeout
 
Glib::Threads::Mutex exception_mutex
 
std::shared_ptr< ThreaderExceptionexception
 

Additional Inherited Members

- Public Types inherited from AudioGrapher::Source< DefaultSampleType >
typedef std::shared_ptr< Sink< DefaultSampleType > > SinkPtr
 

Detailed Description

template<typename T = DefaultSampleType>
class AudioGrapher::Threader< T >

Class for distributing processing across several threads.

Definition at line 38 of file threader.h.

Member Typedef Documentation

◆ OutputVec

template<typename T = DefaultSampleType>
typedef std::vector<typename Source<T>::SinkPtr> AudioGrapher::Threader< T >::OutputVec
private

Definition at line 41 of file threader.h.

Constructor & Destructor Documentation

◆ Threader()

template<typename T = DefaultSampleType>
AudioGrapher::Threader< T >::Threader ( Glib::ThreadPool &  thread_pool,
long  wait_timeout_milliseconds = 500 
)
inline

Constructor
RT safe

Parameters
thread_poola thread pool from which all tasks are scheduled
wait_timeout_millisecondsmaximum time allowed for threads to use in processing

Definition at line 50 of file threader.h.

◆ ~Threader()

template<typename T = DefaultSampleType>
virtual AudioGrapher::Threader< T >::~Threader ( )
inlinevirtual

Definition at line 57 of file threader.h.

Member Function Documentation

◆ add_output()

template<typename T = DefaultSampleType>
void AudioGrapher::Threader< T >::add_output ( typename Source< T >::SinkPtr  output)
inline

Adds output
RT safe.

Definition at line 60 of file threader.h.

◆ clear_outputs()

template<typename T = DefaultSampleType>
void AudioGrapher::Threader< T >::clear_outputs ( )
inlinevirtual

Clears outputs
RT safe.

Implements AudioGrapher::Source< DefaultSampleType >.

Definition at line 63 of file threader.h.

◆ process()

template<typename T = DefaultSampleType>
void AudioGrapher::Threader< T >::process ( ProcessContext< T > const &  c)
inline

Processes context concurrently by scheduling each output separately to the given thread pool.

Definition at line 72 of file threader.h.

◆ process_output()

template<typename T = DefaultSampleType>
void AudioGrapher::Threader< T >::process_output ( ProcessContext< T > const &  c,
unsigned int  output 
)
inlineprivate

Definition at line 105 of file threader.h.

◆ remove_output()

template<typename T = DefaultSampleType>
void AudioGrapher::Threader< T >::remove_output ( typename Source< T >::SinkPtr  output)
inline

Removes a specific output
RT safe.

Definition at line 66 of file threader.h.

◆ wait()

template<typename T = DefaultSampleType>
void AudioGrapher::Threader< T >::wait ( )
inlineprivate

Definition at line 91 of file threader.h.

Member Data Documentation

◆ exception

template<typename T = DefaultSampleType>
std::shared_ptr<ThreaderException> AudioGrapher::Threader< T >::exception
private

Definition at line 131 of file threader.h.

◆ exception_mutex

template<typename T = DefaultSampleType>
Glib::Threads::Mutex AudioGrapher::Threader< T >::exception_mutex
private

Definition at line 130 of file threader.h.

◆ outputs

template<typename T = DefaultSampleType>
OutputVec AudioGrapher::Threader< T >::outputs
private

Definition at line 121 of file threader.h.

◆ readers

template<typename T = DefaultSampleType>
std::atomic<int> AudioGrapher::Threader< T >::readers
private

Definition at line 127 of file threader.h.

◆ thread_pool

template<typename T = DefaultSampleType>
Glib::ThreadPool& AudioGrapher::Threader< T >::thread_pool
private

Definition at line 123 of file threader.h.

◆ wait_cond

template<typename T = DefaultSampleType>
Glib::Threads::Cond AudioGrapher::Threader< T >::wait_cond
private

Definition at line 125 of file threader.h.

◆ wait_mutex

template<typename T = DefaultSampleType>
Glib::Threads::Mutex AudioGrapher::Threader< T >::wait_mutex
private

Definition at line 124 of file threader.h.

◆ wait_timeout

template<typename T = DefaultSampleType>
long AudioGrapher::Threader< T >::wait_timeout
private

Definition at line 128 of file threader.h.


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