1 #ifndef AUDIOGRAPHER_THREADER_H
2 #define AUDIOGRAPHER_THREADER_H
8 #include "glibmm/threads.h"
9 #include <glibmm/threadpool.h>
10 #include <glibmm/timeval.h>
11 #include <sigc++/slot.h>
37 template <
typename T = DefaultSampleType>
41 typedef std::vector<typename Source<T>::SinkPtr>
OutputVec;
67 typename OutputVec::iterator new_end = std::remove(
outputs.begin(),
outputs.end(), output);
78 unsigned int outs =
outputs.size();
79 (void)
readers.fetch_add (outs);
80 for (
unsigned int i = 0; i < outs; ++i) {
94 gint64 end_time = g_get_monotonic_time () + (
wait_timeout * G_TIME_SPAN_MILLISECOND);
109 }
catch (std::exception
const & e) {
const char * what() const
std::shared_ptr< Sink< T > > SinkPtr
Class that stores exceptions thrown from different threads.
ThreaderException(T const &thrower, std::exception const &e)
Class for distributing processing across several threads.
Glib::ThreadPool & thread_pool
Glib::Threads::Mutex wait_mutex
void add_output(typename Source< T >::SinkPtr output)
Adds output RT safe.
Glib::Threads::Mutex exception_mutex
void process(ProcessContext< T > const &c)
Processes context concurrently by scheduling each output separately to the given thread pool.
Threader(Glib::ThreadPool &thread_pool, long wait_timeout_milliseconds=500)
std::vector< typename Source< T >::SinkPtr > OutputVec
void clear_outputs()
Clears outputs RT safe.
void remove_output(typename Source< T >::SinkPtr output)
Removes a specific output RT safe.
std::shared_ptr< ThreaderException > exception
void process_output(ProcessContext< T > const &c, unsigned int output)
Glib::Threads::Cond wait_cond
std::atomic< int > readers
std::string string_compose(const std::string &fmt, const T1 &o1)
bool atomic_dec_and_test(std::atomic< T > &aval)
std::string demangled_name(T const &obj)