diff --git a/include/dspatch/Circuit.h b/include/dspatch/Circuit.h index ce1d1042..01a41040 100644 --- a/include/dspatch/Circuit.h +++ b/include/dspatch/Circuit.h @@ -300,7 +300,7 @@ class Circuit final for ( auto component : *_components ) { - component->TickSeries( _bufferNo ); + component->Tick( _bufferNo ); } } } @@ -316,20 +316,20 @@ class Circuit final std::condition_variable _resumeCondt, _syncCondt; }; - class ParallelCircuitThread final + class CircuitThreadParallel final { public: - ParallelCircuitThread( const ParallelCircuitThread& ) = delete; - ParallelCircuitThread& operator=( const ParallelCircuitThread& ) = delete; + CircuitThreadParallel( const CircuitThreadParallel& ) = delete; + CircuitThreadParallel& operator=( const CircuitThreadParallel& ) = delete; - inline ParallelCircuitThread() = default; + inline CircuitThreadParallel() = default; // cppcheck-suppress missingMemberCopy - inline ParallelCircuitThread( ParallelCircuitThread&& ) + inline CircuitThreadParallel( CircuitThreadParallel&& ) { } - inline ~ParallelCircuitThread() + inline ~CircuitThreadParallel() { Stop(); } @@ -344,7 +344,7 @@ class Circuit final _stop = false; _gotSync = false; - _thread = std::thread( &ParallelCircuitThread::_Run, this ); + _thread = std::thread( &CircuitThreadParallel::_Run, this ); } inline void Stop() @@ -430,12 +430,13 @@ class Circuit final AutoTickThread _autoTickThread; - std::vector _components; std::set _componentsSet; + + std::vector _components; std::vector _componentsParallel; std::vector _circuitThreads; - std::vector> _parallelCircuitThreads; + std::vector> _circuitThreadsParallel; bool _circuitDirty = false; }; @@ -633,7 +634,7 @@ inline void Circuit::SetThreadCount( int threadCount ) _threadCount = threadCount; // stop all threads - for ( auto& circuitThreads : _parallelCircuitThreads ) + for ( auto& circuitThreads : _circuitThreadsParallel ) { for ( auto& circuitThread : circuitThreads ) { @@ -644,20 +645,20 @@ inline void Circuit::SetThreadCount( int threadCount ) // resize thread array if ( _threadCount == 0 ) { - _parallelCircuitThreads.resize( 0 ); + _circuitThreadsParallel.resize( 0 ); SetBufferCount( _bufferCount ); } else { - _parallelCircuitThreads.resize( _bufferCount == 0 ? 1 : _bufferCount ); - for ( auto& circuitThread : _parallelCircuitThreads ) + _circuitThreadsParallel.resize( _bufferCount == 0 ? 1 : _bufferCount ); + for ( auto& circuitThread : _circuitThreadsParallel ) { circuitThread.resize( _threadCount ); } // initialise and start all threads int i = 0; - for ( auto& circuitThreads : _parallelCircuitThreads ) + for ( auto& circuitThreads : _circuitThreadsParallel ) { int j = 0; for ( auto& circuitThread : circuitThreads ) @@ -691,7 +692,7 @@ inline void Circuit::Tick() // tick all internal components for ( auto component : _components ) { - component->TickSeries( 0 ); + component->Tick( 0 ); } return; @@ -700,7 +701,7 @@ inline void Circuit::Tick() // ======================================================= else if ( _threadCount != 0 ) { - auto& circuitThreads = _parallelCircuitThreads[_currentBuffer]; + auto& circuitThreads = _circuitThreadsParallel[_currentBuffer]; for ( auto& circuitThread : circuitThreads ) { @@ -729,7 +730,7 @@ inline void Circuit::Sync() { circuitThread.Sync(); } - for ( auto& circuitThreads : _parallelCircuitThreads ) + for ( auto& circuitThreads : _circuitThreadsParallel ) { for ( auto& circuitThread : circuitThreads ) { @@ -779,7 +780,7 @@ inline void Circuit::_Optimize() for ( auto component : _components ) { - component->ScanSeries( orderedComponents ); + component->Scan( orderedComponents ); } for ( auto component : _components ) { diff --git a/include/dspatch/Component.h b/include/dspatch/Component.h index 20616b4d..d5cfef53 100644 --- a/include/dspatch/Component.h +++ b/include/dspatch/Component.h @@ -93,10 +93,10 @@ class Component void SetBufferCount( int bufferCount, int startBuffer ); int GetBufferCount() const; - void TickSeries( int bufferNo ); + void Tick( int bufferNo ); void TickParallel( int bufferNo ); - void ScanSeries( std::vector& components ); + void Scan( std::vector& components ); void ScanParallel( std::vector>& componentsMap, int& scanPosition ); void EndScan(); @@ -356,7 +356,7 @@ inline int Component::GetBufferCount() const return (int)_inputBuses.size(); } -inline void Component::TickSeries( int bufferNo ) +inline void Component::Tick( int bufferNo ) { auto& inputBus = _inputBuses[bufferNo]; auto& outputBus = _outputBuses[bufferNo]; @@ -434,7 +434,7 @@ inline void Component::TickParallel( int bufferNo ) } } -inline void Component::ScanSeries( std::vector& components ) +inline void Component::Scan( std::vector& components ) { // continue only if this component has not already been scanned if ( _scanPosition != -1 ) @@ -448,7 +448,7 @@ inline void Component::ScanSeries( std::vector& components ) for ( const auto& wire : _inputWires ) { // scan incoming components - wire.fromComponent->ScanSeries( components ); + wire.fromComponent->Scan( components ); } components.emplace_back( this ); diff --git a/tests/main.cpp b/tests/main.cpp index 131c9ebf..a6d9517d 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -271,10 +271,10 @@ TEST_CASE( "FeedbackTestNoCircuit" ) // Tick the circuit 100 times for ( int i = 0; i < 100; ++i ) { - counter->TickSeries( 0 ); - adder->TickSeries( 0 ); - passthrough->TickSeries( 0 ); - probe->TickSeries( 0 ); + counter->Tick( 0 ); + adder->Tick( 0 ); + passthrough->Tick( 0 ); + probe->Tick( 0 ); } }