31#include <dspatch/Component.h>
34#define WIN32_LEAN_AND_MEAN
36#undef WIN32_LEAN_AND_MEAN
39#include <condition_variable>
82 inline void Start( std::vector<DSPatch::Component*>* components,
int bufferNo,
int threadNo,
int threadCount )
84 _components = components;
87 _threadCount = threadCount;
92 _thread = std::thread( &ParallelCircuitThread::_Run,
this );
101 if ( _thread.joinable() )
109 std::unique_lock<std::mutex> lock( _syncMutex );
113 _syncCondt.wait( lock );
120 _resumeCondt.notify_all();
127 SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_HIGHEST );
129 sched_param sch_params;
130 sch_params.sched_priority = sched_get_priority_max( SCHED_RR );
131 pthread_setschedparam( pthread_self(), SCHED_RR, &sch_params );
139 std::unique_lock<std::mutex> lock( _syncMutex );
142 _syncCondt.notify_all();
143 _resumeCondt.wait( lock );
149 for (
auto it = _components->begin() + _threadNo; it < _components->end(); it += _threadCount )
151 ( *it )->TickParallel( _bufferNo );
159 std::vector<DSPatch::Component*>* _components =
nullptr;
162 int _threadCount = 0;
164 bool _gotSync =
false;
165 std::mutex _syncMutex;
166 std::condition_variable _resumeCondt, _syncCondt;
Thread class for asynchronously ticking parallel circuit components.