DSPatch v.10.2.3
Loading...
Searching...
No Matches
Public Member Functions | List of all members
DSPatch::Circuit Class Referencefinal

Workspace for adding and routing components. More...

#include <Circuit.h>

Public Member Functions

 NONCOPYABLE (Circuit)
 
bool AddComponent (const Component::SPtr &component)
 
bool RemoveComponent (const Component::SPtr &component)
 
void RemoveAllComponents ()
 
int GetComponentCount () const
 
bool ConnectOutToIn (const Component::SPtr &fromComponent, int fromOutput, const Component::SPtr &toComponent, int toInput)
 
bool DisconnectComponent (const Component::SPtr &component)
 
void DisconnectAllComponents ()
 
void SetBufferCount (int bufferCount)
 
int GetBufferCount () const
 
void SetThreadCount (int threadCount)
 
int GetThreadCount () const
 
void Tick ()
 
void Sync ()
 
void StartAutoTick ()
 
void StopAutoTick ()
 
void PauseAutoTick ()
 
void ResumeAutoTick ()
 
void Optimize ()
 

Detailed Description

Workspace for adding and routing components.

Components can be added to a Circuit via the AddComponent() method, and routed to and from other components via the ConnectOutToIn() method.

NOTE: Each component input can only accept a single "wire" at a time. When a wire is connected to an input that already has a connected wire, that wire is replaced with the new one. One output, on the other hand, can be distributed to multiple inputs.

To boost performance in stream processing circuits, multi-buffering can be enabled via the SetBufferCount() method. A circuit's buffer count can be adjusted at runtime.

NOTE: If none of the parallel branches in your circuit are time-consuming (⪆10μs), multi-buffering (or even zero buffering) will almost always outperform multi-threading (via SetThreadCount()). The contention overhead caused by multiple threads processing a single tick must be made negligible by time-consuming parallel components for any performance improvement to be seen.

The Circuit Tick() method runs through its internal array of components and calls each component's Tick() method. A circuit's Tick() method can be called in a loop from the main application thread, or alternatively, by calling StartAutoTick(), a separate thread will spawn, automatically calling Tick() continuously until PauseAutoTick() or StopAutoTick() is called.

The Circuit Optimize() method rearranges components such that they process in the most optimal order during Tick(). This optimization will occur automatically during the first Tick() proceeding any calls to ConnectOutToIn(), however, if you'd like to pre-order components before the next Tick() is processed, you can call Optimize() manually.

Definition at line 66 of file Circuit.h.


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