DSPatch  v.5.01
Public Member Functions | List of all members
DSPatch::internal::CircuitThread Class Referencefinal

Thread class for asynchronously ticking circuit components. More...

#include <CircuitThread.h>

Public Member Functions

 NONCOPYABLE (CircuitThread)
 
 DEFINE_PTRS (CircuitThread)
 
void Initialise (std::vector< DSPatch::Component::SPtr > *components, int threadNo)
 
void Start ()
 
void Stop ()
 
void Sync ()
 
void SyncAndResume ()
 

Detailed Description

Thread class for asynchronously ticking circuit components.

A CircuitThread is responsible for ticking and reseting all components within a Circuit. Upon initialisation, a reference to the vector of circuit components must be provided for the thread _Run() method to loop through. Each CircuitThread has a thread number (threadNo), which is also provided upon initialisation. When creating multiple CircuitThreads, each thread must have their own unique thread number, beginning at 0 and incrementing by 1 for every thread added. This thread number corresponds with the Component's buffer number when calling it's Tick() and Reset() methods in the CircuitThread's component loop. Hence, for every circuit thread created, each component's buffer count within that circuit must be incremented to match.

The SyncAndResume() method causes the CircuitThread to tick and reset all circuit components once, after which the thread will wait until instructed to resume again. As each component is done processing it hands over control to the next waiting circuit thread, therefore, from an external control loop (I.e. Circuit's Tick() method) we can simply loop through our array of CircuitThreads calling SyncAndResume() on each. If a circuit thread is busy processing, a call to SyncAndResume() will block momentarily until that thread is done processing.

Definition at line 57 of file CircuitThread.h.


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