DSPatch v.11.4.1
Loading...
Searching...
No Matches
DSPatch::Circuit Class Referencefinal

Workspace for adding and routing components. More...

#include <Circuit.h>

Public Member Functions

 Circuit (const Circuit &)=delete
 
Circuitoperator= (const Circuit &)=delete
 
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 connection / disconnection, however, if you'd like to pre-order components before the next Tick() is processed, you can call Optimize() manually.

Definition at line 72 of file Circuit.h.

Constructor & Destructor Documentation

◆ ~Circuit()

DSPatch::Circuit::~Circuit ( )
inline

Definition at line 454 of file Circuit.h.

Member Function Documentation

◆ AddComponent()

bool DSPatch::Circuit::AddComponent ( const Component::SPtr & component)
inline

Definition at line 460 of file Circuit.h.

◆ ConnectOutToIn()

bool DSPatch::Circuit::ConnectOutToIn ( const Component::SPtr & fromComponent,
int fromOutput,
const Component::SPtr & toComponent,
int toInput )
inline

Definition at line 527 of file Circuit.h.

◆ DisconnectAllComponents()

void DSPatch::Circuit::DisconnectAllComponents ( )
inline

Definition at line 573 of file Circuit.h.

◆ DisconnectComponent()

bool DSPatch::Circuit::DisconnectComponent ( const Component::SPtr & component)
inline

Definition at line 549 of file Circuit.h.

◆ GetBufferCount()

int DSPatch::Circuit::GetBufferCount ( ) const
inline

Definition at line 628 of file Circuit.h.

◆ GetComponentCount()

int DSPatch::Circuit::GetComponentCount ( ) const
inline

Definition at line 522 of file Circuit.h.

◆ GetThreadCount()

int DSPatch::Circuit::GetThreadCount ( ) const
inline

Definition at line 679 of file Circuit.h.

◆ Optimize()

void DSPatch::Circuit::Optimize ( )
inline

Definition at line 767 of file Circuit.h.

◆ PauseAutoTick()

void DSPatch::Circuit::PauseAutoTick ( )
inline

Definition at line 756 of file Circuit.h.

◆ RemoveAllComponents()

void DSPatch::Circuit::RemoveAllComponents ( )
inline

Definition at line 508 of file Circuit.h.

◆ RemoveComponent()

bool DSPatch::Circuit::RemoveComponent ( const Component::SPtr & component)
inline

Definition at line 480 of file Circuit.h.

◆ ResumeAutoTick()

void DSPatch::Circuit::ResumeAutoTick ( )
inline

Definition at line 762 of file Circuit.h.

◆ SetBufferCount()

void DSPatch::Circuit::SetBufferCount ( int bufferCount)
inline

Definition at line 585 of file Circuit.h.

◆ SetThreadCount()

void DSPatch::Circuit::SetThreadCount ( int threadCount)
inline

Definition at line 633 of file Circuit.h.

◆ StartAutoTick()

void DSPatch::Circuit::StartAutoTick ( )
inline

Definition at line 745 of file Circuit.h.

◆ StopAutoTick()

void DSPatch::Circuit::StopAutoTick ( )
inline

Definition at line 750 of file Circuit.h.

◆ Sync()

void DSPatch::Circuit::Sync ( )
inline

Definition at line 729 of file Circuit.h.

◆ Tick()

void DSPatch::Circuit::Tick ( )
inline

Definition at line 684 of file Circuit.h.


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