diff --git a/CHANGES b/CHANGES index c60ad6e1..8f8274fa 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +v.11.1.3 (30 March 2024) + - Added componentsMap reserve() in Circuit::_Optimize(). + - Slightly optimized Component::ConnectInput(). + - Cleaned up a couple for loops. + v.11.1.2 (28 March 2024) - Updated fast_any submodule (incl. const T& constructor). - Added DisconnectAllComponents() call to Circuit destructor. diff --git a/docs/Doxyfile b/docs/Doxyfile index 9380779f..09c59fe4 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -32,7 +32,7 @@ PROJECT_NAME = DSPatch # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = v.11.1.2 +PROJECT_NUMBER = v.11.1.3 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer diff --git a/docs/html/_circuit_8h_source.html b/docs/html/_circuit_8h_source.html index f5219b1f..301d0f79 100644 --- a/docs/html/_circuit_8h_source.html +++ b/docs/html/_circuit_8h_source.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
@@ -849,30 +849,31 @@
794 if ( _threadCount != 0 )
795 {
796 std::vector<std::vector<DSPatch::Component*>> componentsMap;
-
797
-
798 for ( int i = (int)_components.size() - 1; i >= 0; --i )
-
799 {
-
800 int scanPosition;
-
801 _components[i]->ScanParallel( componentsMap, scanPosition );
-
802 }
-
803 for ( auto component : _components )
-
804 {
-
805 component->EndScan();
-
806 }
-
807
-
808 _componentsParallel.clear();
-
809 _componentsParallel.reserve( _components.size() );
-
810 for ( auto& componentsMapEntry : componentsMap )
-
811 {
-
812 _componentsParallel.insert( _componentsParallel.end(), componentsMapEntry.begin(), componentsMapEntry.end() );
-
813 }
-
814 }
-
815
-
816 // clear _circuitDirty flag
-
817 _circuitDirty = false;
-
818}
-
819
-
820} // namespace DSPatch
+
797 componentsMap.reserve( _components.size() );
+
798
+
799 int scanPosition;
+
800 for ( int i = (int)_components.size() - 1; i >= 0; --i )
+
801 {
+
802 _components[i]->ScanParallel( componentsMap, scanPosition );
+
803 }
+
804 for ( auto component : _components )
+
805 {
+
806 component->EndScan();
+
807 }
+
808
+
809 _componentsParallel.clear();
+
810 _componentsParallel.reserve( _components.size() );
+
811 for ( auto& componentsMapEntry : componentsMap )
+
812 {
+
813 _componentsParallel.insert( _componentsParallel.end(), componentsMapEntry.begin(), componentsMapEntry.end() );
+
814 }
+
815 }
+
816
+
817 // clear _circuitDirty flag
+
818 _circuitDirty = false;
+
819}
+
820
+
821} // namespace DSPatch
Workspace for adding and routing components.
Definition Circuit.h:73
diff --git a/docs/html/_component_8h_source.html b/docs/html/_component_8h_source.html index c8afde72..f3b394a4 100644 --- a/docs/html/_component_8h_source.html +++ b/docs/html/_component_8h_source.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
@@ -251,7 +251,7 @@
193
194inline bool Component::ConnectInput( const Component::SPtr& fromComponent, int fromOutput, int toInput )
195{
-
196 if ( fromOutput >= fromComponent->GetOutputCount() || toInput >= _inputBuses[0].GetSignalCount() )
+
196 if ( fromOutput >= fromComponent->GetOutputCount() || toInput >= GetInputCount() )
197 {
198 return false;
199 }
@@ -264,407 +264,416 @@
206 if ( it->fromComponent == fromComponent.get() && it->fromOutput == fromOutput )
207 {
208 // this wire already exists
-
209 return false;
+
209 return true;
210 }
211
212 // update source output's reference count
213 it->fromComponent->_DecRefs( it->fromOutput );
214
-
215 _inputWires.erase( it );
-
216 }
-
217
-
218 _inputWires.emplace_back( Wire{ fromComponent.get(), fromOutput, toInput } );
-
219
-
220 // update source output's reference count
-
221 fromComponent->_IncRefs( fromOutput );
-
222
-
223 return true;
-
224}
-
225
-
226inline void Component::DisconnectInput( int inputNo )
-
227{
-
228 // remove wires connected to inputNo from _inputWires
-
229 auto findFn = [&inputNo]( const auto& wire ) { return wire.toInput == inputNo; };
+
215 // replace wire
+
216 it->fromComponent = fromComponent.get();
+
217 it->fromOutput = fromOutput;
+
218 }
+
219 else
+
220 {
+
221 // add new wire
+
222 _inputWires.emplace_back( Wire{ fromComponent.get(), fromOutput, toInput } );
+
223 }
+
224
+
225 // update source output's reference count
+
226 fromComponent->_IncRefs( fromOutput );
+
227
+
228 return true;
+
229}
230
-
231 if ( auto it = std::find_if( _inputWires.begin(), _inputWires.end(), findFn ); it != _inputWires.end() )
-
232 {
-
233 // update source output's reference count
-
234 it->fromComponent->_DecRefs( it->fromOutput );
+
231inline void Component::DisconnectInput( int inputNo )
+
232{
+
233 // remove wires connected to inputNo from _inputWires
+
234 auto findFn = [&inputNo]( const auto& wire ) { return wire.toInput == inputNo; };
235
-
236 _inputWires.erase( it );
-
237 }
-
238}
-
239
-
240inline void Component::DisconnectInput( const Component::SPtr& fromComponent )
-
241{
-
242 // remove fromComponent from _inputWires
-
243 auto findFn = [&fromComponent]( const auto& wire ) { return wire.fromComponent == fromComponent.get(); };
+
236 if ( auto it = std::find_if( _inputWires.begin(), _inputWires.end(), findFn ); it != _inputWires.end() )
+
237 {
+
238 // update source output's reference count
+
239 it->fromComponent->_DecRefs( it->fromOutput );
+
240
+
241 _inputWires.erase( it );
+
242 }
+
243}
244
-
245 for ( auto it = std::find_if( _inputWires.begin(), _inputWires.end(), findFn ); it != _inputWires.end();
-
246 it = std::find_if( it, _inputWires.end(), findFn ) )
-
247 {
-
248 // update source output's reference count
-
249 fromComponent->_DecRefs( it->fromOutput );
-
250
-
251 it = _inputWires.erase( it );
-
252 }
-
253}
-
254
-
255inline void Component::DisconnectAllInputs()
-
256{
-
257 // remove all wires from _inputWires
-
258 for ( const auto& wire : _inputWires )
-
259 {
-
260 // update source output's reference count
-
261 wire.fromComponent->_DecRefs( wire.fromOutput );
-
262 }
-
263
-
264 _inputWires.clear();
-
265}
-
266
-
267inline int Component::GetInputCount() const
-
268{
-
269 return _inputBuses[0].GetSignalCount();
+
245inline void Component::DisconnectInput( const Component::SPtr& fromComponent )
+
246{
+
247 // remove fromComponent from _inputWires
+
248 auto findFn = [&fromComponent]( const auto& wire ) { return wire.fromComponent == fromComponent.get(); };
+
249
+
250 for ( auto it = std::find_if( _inputWires.begin(), _inputWires.end(), findFn ); it != _inputWires.end();
+
251 it = std::find_if( it, _inputWires.end(), findFn ) )
+
252 {
+
253 // update source output's reference count
+
254 fromComponent->_DecRefs( it->fromOutput );
+
255
+
256 it = _inputWires.erase( it );
+
257 }
+
258}
+
259
+
260inline void Component::DisconnectAllInputs()
+
261{
+
262 // remove all wires from _inputWires
+
263 for ( const auto& wire : _inputWires )
+
264 {
+
265 // update source output's reference count
+
266 wire.fromComponent->_DecRefs( wire.fromOutput );
+
267 }
+
268
+
269 _inputWires.clear();
270}
271
-
272inline int Component::GetOutputCount() const
+
272inline int Component::GetInputCount() const
273{
-
274 return _outputBuses[0].GetSignalCount();
+
274 return _inputBuses[0].GetSignalCount();
275}
276
-
277// cppcheck-suppress unusedFunction
-
278inline std::string Component::GetInputName( int inputNo ) const
-
279{
-
280 if ( inputNo < (int)_inputNames.size() )
-
281 {
-
282 return _inputNames[inputNo];
-
283 }
-
284 return "";
-
285}
-
286
-
287// cppcheck-suppress unusedFunction
-
288inline std::string Component::GetOutputName( int outputNo ) const
-
289{
-
290 if ( outputNo < (int)_outputNames.size() )
-
291 {
-
292 return _outputNames[outputNo];
-
293 }
-
294 return "";
-
295}
-
296
-
297inline void Component::SetBufferCount( int bufferCount, int startBuffer )
-
298{
-
299 // _bufferCount is the current thread count / bufferCount is new thread count
-
300
-
301 if ( bufferCount <= 0 )
-
302 {
-
303 bufferCount = 1; // there needs to be at least 1 buffer
-
304 }
+
277inline int Component::GetOutputCount() const
+
278{
+
279 return _outputBuses[0].GetSignalCount();
+
280}
+
281
+
282// cppcheck-suppress unusedFunction
+
283inline std::string Component::GetInputName( int inputNo ) const
+
284{
+
285 if ( inputNo < (int)_inputNames.size() )
+
286 {
+
287 return _inputNames[inputNo];
+
288 }
+
289 return "";
+
290}
+
291
+
292// cppcheck-suppress unusedFunction
+
293inline std::string Component::GetOutputName( int outputNo ) const
+
294{
+
295 if ( outputNo < (int)_outputNames.size() )
+
296 {
+
297 return _outputNames[outputNo];
+
298 }
+
299 return "";
+
300}
+
301
+
302inline void Component::SetBufferCount( int bufferCount, int startBuffer )
+
303{
+
304 // _bufferCount is the current thread count / bufferCount is new thread count
305
-
306 if ( startBuffer >= bufferCount )
+
306 if ( bufferCount <= 0 )
307 {
-
308 startBuffer = 0;
+
308 bufferCount = 1; // there needs to be at least 1 buffer
309 }
310
-
311 // resize vectors
-
312 _inputBuses.resize( bufferCount );
-
313 _outputBuses.resize( bufferCount );
-
314
-
315 _releaseFlags.resize( bufferCount );
-
316
-
317 _refs.resize( bufferCount );
-
318 auto refCount = _refs[0].size();
+
311 if ( startBuffer >= bufferCount )
+
312 {
+
313 startBuffer = 0;
+
314 }
+
315
+
316 // resize vectors
+
317 _inputBuses.resize( bufferCount );
+
318 _outputBuses.resize( bufferCount );
319
-
320 // init vector values
-
321 for ( int i = 0; i < bufferCount; ++i )
-
322 {
-
323 _inputBuses[i].SetSignalCount( _inputBuses[0].GetSignalCount() );
-
324 _outputBuses[i].SetSignalCount( _outputBuses[0].GetSignalCount() );
-
325
-
326 if ( i == startBuffer )
-
327 {
-
328 _releaseFlags[i].Set();
-
329 }
-
330 else
-
331 {
-
332 _releaseFlags[i].Clear();
-
333 }
-
334
-
335 _refs[i].resize( refCount );
-
336 for ( size_t j = 0; j < refCount; ++j )
-
337 {
-
338 // sync output reference counts
-
339 _refs[i][j].total = _refs[0][j].total;
-
340 }
-
341 }
+
320 _releaseFlags.resize( bufferCount );
+
321
+
322 _refs.resize( bufferCount );
+
323
+
324 const auto inputCount = GetInputCount();
+
325 const auto outputCount = GetOutputCount();
+
326 const auto refCount = _refs[0].size();
+
327
+
328 // init vector values
+
329 for ( int i = 0; i < bufferCount; ++i )
+
330 {
+
331 _inputBuses[i].SetSignalCount( inputCount );
+
332 _outputBuses[i].SetSignalCount( outputCount );
+
333
+
334 if ( i == startBuffer )
+
335 {
+
336 _releaseFlags[i].Set();
+
337 }
+
338 else
+
339 {
+
340 _releaseFlags[i].Clear();
+
341 }
342
-
343 _bufferCount = bufferCount;
-
344}
-
345
-
346inline int Component::GetBufferCount() const
-
347{
-
348 return (int)_inputBuses.size();
-
349}
+
343 _refs[i].resize( refCount );
+
344 for ( size_t j = 0; j < refCount; ++j )
+
345 {
+
346 // sync output reference counts
+
347 _refs[i][j].total = _refs[0][j].total;
+
348 }
+
349 }
350
-
351inline void Component::TickSeries( int bufferNo )
-
352{
-
353 auto& inputBus = _inputBuses[bufferNo];
-
354 auto& outputBus = _outputBuses[bufferNo];
-
355
-
356 // clear inputs
-
357 inputBus.ClearAllValues();
+
351 _bufferCount = bufferCount;
+
352}
+
353
+
354inline int Component::GetBufferCount() const
+
355{
+
356 return (int)_inputBuses.size();
+
357}
358
-
359 for ( const auto& wire : _inputWires )
-
360 {
-
361 // get new inputs from incoming components
-
362 wire.fromComponent->_GetOutput( bufferNo, wire.fromOutput, wire.toInput, inputBus );
-
363 }
-
364
-
365 // clear outputs
-
366 outputBus.ClearAllValues();
-
367
-
368 if ( _bufferCount != 1 && _processOrder == ProcessOrder::InOrder )
-
369 {
-
370 // wait for our turn to process
-
371 _WaitForRelease( bufferNo );
+
359inline void Component::TickSeries( int bufferNo )
+
360{
+
361 auto& inputBus = _inputBuses[bufferNo];
+
362 auto& outputBus = _outputBuses[bufferNo];
+
363
+
364 // clear inputs
+
365 inputBus.ClearAllValues();
+
366
+
367 for ( const auto& wire : _inputWires )
+
368 {
+
369 // get new inputs from incoming components
+
370 wire.fromComponent->_GetOutput( bufferNo, wire.fromOutput, wire.toInput, inputBus );
+
371 }
372
-
373 // call Process_() with newly aquired inputs
-
374 Process_( inputBus, outputBus );
+
373 // clear outputs
+
374 outputBus.ClearAllValues();
375
-
376 // signal that we're done processing
-
377 _ReleaseNextThread( bufferNo );
-
378 }
-
379 else
-
380 {
+
376 if ( _bufferCount != 1 && _processOrder == ProcessOrder::InOrder )
+
377 {
+
378 // wait for our turn to process
+
379 _WaitForRelease( bufferNo );
+
380
381 // call Process_() with newly aquired inputs
382 Process_( inputBus, outputBus );
-
383 }
-
384}
-
385
-
386inline void Component::TickParallel( int bufferNo )
-
387{
-
388 auto& inputBus = _inputBuses[bufferNo];
-
389 auto& outputBus = _outputBuses[bufferNo];
-
390
-
391 // clear inputs and outputs
-
392 inputBus.ClearAllValues();
-
393 outputBus.ClearAllValues();
-
394
-
395 for ( const auto& wire : _inputWires )
-
396 {
-
397 // get new inputs from incoming components
-
398 wire.fromComponent->_GetOutputParallel( bufferNo, wire.fromOutput, wire.toInput, inputBus );
-
399 }
-
400
-
401 if ( _bufferCount != 1 && _processOrder == ProcessOrder::InOrder )
-
402 {
-
403 // wait for our turn to process
-
404 _WaitForRelease( bufferNo );
-
405
-
406 // call Process_() with newly aquired inputs
-
407 Process_( inputBus, outputBus );
+
383
+
384 // signal that we're done processing
+
385 _ReleaseNextThread( bufferNo );
+
386 }
+
387 else
+
388 {
+
389 // call Process_() with newly aquired inputs
+
390 Process_( inputBus, outputBus );
+
391 }
+
392}
+
393
+
394inline void Component::TickParallel( int bufferNo )
+
395{
+
396 auto& inputBus = _inputBuses[bufferNo];
+
397 auto& outputBus = _outputBuses[bufferNo];
+
398
+
399 // clear inputs and outputs
+
400 inputBus.ClearAllValues();
+
401 outputBus.ClearAllValues();
+
402
+
403 for ( const auto& wire : _inputWires )
+
404 {
+
405 // get new inputs from incoming components
+
406 wire.fromComponent->_GetOutputParallel( bufferNo, wire.fromOutput, wire.toInput, inputBus );
+
407 }
408
-
409 // signal that we're done processing
-
410 _ReleaseNextThread( bufferNo );
-
411 }
-
412 else
-
413 {
+
409 if ( _bufferCount != 1 && _processOrder == ProcessOrder::InOrder )
+
410 {
+
411 // wait for our turn to process
+
412 _WaitForRelease( bufferNo );
+
413
414 // call Process_() with newly aquired inputs
415 Process_( inputBus, outputBus );
-
416 }
-
417
-
418 // signal that our outputs are ready
-
419 for ( auto& ref : _refs[bufferNo] )
-
420 {
-
421 // readyFlags are cleared in _GetOutputParallel() which ofc is only called on outputs with refs
-
422 if ( ref.total != 0 )
-
423 {
-
424 ref.readyFlag.Set();
-
425 }
-
426 }
-
427}
-
428
-
429inline void Component::ScanSeries( std::vector<Component*>& components )
-
430{
-
431 // continue only if this component has not already been scanned
-
432 if ( _scanPosition != -1 )
-
433 {
-
434 return;
-
435 }
+
416
+
417 // signal that we're done processing
+
418 _ReleaseNextThread( bufferNo );
+
419 }
+
420 else
+
421 {
+
422 // call Process_() with newly aquired inputs
+
423 Process_( inputBus, outputBus );
+
424 }
+
425
+
426 // signal that our outputs are ready
+
427 for ( auto& ref : _refs[bufferNo] )
+
428 {
+
429 // readyFlags are cleared in _GetOutputParallel() which ofc is only called on outputs with refs
+
430 if ( ref.total != 0 )
+
431 {
+
432 ref.readyFlag.Set();
+
433 }
+
434 }
+
435}
436
-
437 // initialize _scanPosition
-
438 _scanPosition = 0;
-
439
-
440 for ( const auto& wire : _inputWires )
+
437inline void Component::ScanSeries( std::vector<Component*>& components )
+
438{
+
439 // continue only if this component has not already been scanned
+
440 if ( _scanPosition != -1 )
441 {
-
442 // scan incoming components
-
443 wire.fromComponent->ScanSeries( components );
-
444 }
-
445
-
446 components.emplace_back( this );
-
447}
-
448
-
449inline void Component::ScanParallel( std::vector<std::vector<DSPatch::Component*>>& componentsMap, int& scanPosition )
-
450{
-
451 // continue only if this component has not already been scanned
-
452 if ( _scanPosition != -1 )
-
453 {
-
454 scanPosition = _scanPosition;
-
455 return;
-
456 }
-
457
-
458 // initialize scanPositions
-
459 _scanPosition = 0;
-
460 scanPosition = 0;
-
461
-
462 for ( const auto& wire : _inputWires )
-
463 {
-
464 // scan incoming components
-
465 wire.fromComponent->ScanParallel( componentsMap, scanPosition );
-
466
-
467 // ensure we're using the furthest scanPosition detected
-
468 _scanPosition = std::max( _scanPosition, ++scanPosition );
-
469 }
-
470
-
471 // insert component at _scanPosition
-
472 if ( _scanPosition >= (int)componentsMap.size() )
-
473 {
-
474 componentsMap.resize( _scanPosition + 1 );
-
475 }
-
476 componentsMap[_scanPosition].emplace_back( this );
-
477}
+
442 return;
+
443 }
+
444
+
445 // initialize _scanPosition
+
446 _scanPosition = 0;
+
447
+
448 for ( const auto& wire : _inputWires )
+
449 {
+
450 // scan incoming components
+
451 wire.fromComponent->ScanSeries( components );
+
452 }
+
453
+
454 components.emplace_back( this );
+
455}
+
456
+
457inline void Component::ScanParallel( std::vector<std::vector<DSPatch::Component*>>& componentsMap, int& scanPosition )
+
458{
+
459 // continue only if this component has not already been scanned
+
460 if ( _scanPosition != -1 )
+
461 {
+
462 scanPosition = _scanPosition;
+
463 return;
+
464 }
+
465
+
466 // initialize scanPositions
+
467 _scanPosition = 0;
+
468 scanPosition = 0;
+
469
+
470 for ( const auto& wire : _inputWires )
+
471 {
+
472 // scan incoming components
+
473 wire.fromComponent->ScanParallel( componentsMap, scanPosition );
+
474
+
475 // ensure we're using the furthest scanPosition detected
+
476 _scanPosition = std::max( _scanPosition, ++scanPosition );
+
477 }
478
-
479inline void Component::EndScan()
-
480{
-
481 // reset _scanPosition
-
482 _scanPosition = -1;
-
483}
-
484
-
485inline void Component::SetInputCount_( int inputCount, const std::vector<std::string>& inputNames )
-
486{
-
487 _inputNames = inputNames;
-
488
-
489 for ( auto& inputBus : _inputBuses )
-
490 {
-
491 inputBus.SetSignalCount( inputCount );
-
492 }
+
479 // insert component at _scanPosition
+
480 if ( _scanPosition == (int)componentsMap.size() )
+
481 {
+
482 componentsMap.emplace_back( std::vector<DSPatch::Component*>{} );
+
483 componentsMap[_scanPosition].reserve( componentsMap.capacity() );
+
484 }
+
485 componentsMap[_scanPosition].emplace_back( this );
+
486}
+
487
+
488inline void Component::EndScan()
+
489{
+
490 // reset _scanPosition
+
491 _scanPosition = -1;
+
492}
493
-
494 _inputWires.reserve( inputCount );
-
495}
-
496
-
497inline void Component::SetOutputCount_( int outputCount, const std::vector<std::string>& outputNames )
-
498{
-
499 _outputNames = outputNames;
-
500
-
501 for ( auto& outputBus : _outputBuses )
-
502 {
-
503 outputBus.SetSignalCount( outputCount );
-
504 }
+
494inline void Component::SetInputCount_( int inputCount, const std::vector<std::string>& inputNames )
+
495{
+
496 _inputNames = inputNames;
+
497
+
498 for ( auto& inputBus : _inputBuses )
+
499 {
+
500 inputBus.SetSignalCount( inputCount );
+
501 }
+
502
+
503 _inputWires.reserve( inputCount );
+
504}
505
-
506 // add reference counters for our new outputs
-
507 for ( auto& ref : _refs )
-
508 {
-
509 ref.resize( outputCount );
-
510 }
-
511}
-
512
-
513inline void Component::_WaitForRelease( int threadNo )
-
514{
-
515 _releaseFlags[threadNo].WaitAndClear();
-
516}
-
517
-
518inline void Component::_ReleaseNextThread( int threadNo )
-
519{
-
520 if ( ++threadNo == _bufferCount ) // we're actually releasing the next available thread
-
521 {
-
522 _releaseFlags[0].Set();
-
523 }
-
524 else
-
525 {
-
526 _releaseFlags[threadNo].Set();
-
527 }
-
528}
-
529
-
530inline void Component::_GetOutput( int bufferNo, int fromOutput, int toInput, DSPatch::SignalBus& toBus )
-
531{
-
532 auto& signal = *_outputBuses[bufferNo].GetSignal( fromOutput );
-
533
-
534 if ( !signal.has_value() )
-
535 {
-
536 return;
-
537 }
+
506inline void Component::SetOutputCount_( int outputCount, const std::vector<std::string>& outputNames )
+
507{
+
508 _outputNames = outputNames;
+
509
+
510 for ( auto& outputBus : _outputBuses )
+
511 {
+
512 outputBus.SetSignalCount( outputCount );
+
513 }
+
514
+
515 // add reference counters for our new outputs
+
516 for ( auto& ref : _refs )
+
517 {
+
518 ref.resize( outputCount );
+
519 }
+
520}
+
521
+
522inline void Component::_WaitForRelease( int threadNo )
+
523{
+
524 _releaseFlags[threadNo].WaitAndClear();
+
525}
+
526
+
527inline void Component::_ReleaseNextThread( int threadNo )
+
528{
+
529 if ( ++threadNo == _bufferCount ) // we're actually releasing the next available thread
+
530 {
+
531 _releaseFlags[0].Set();
+
532 }
+
533 else
+
534 {
+
535 _releaseFlags[threadNo].Set();
+
536 }
+
537}
538
-
539 auto& ref = _refs[bufferNo][fromOutput];
-
540
-
541 if ( ref.total == 1 )
-
542 {
-
543 // there's only one reference, move the signal immediately
-
544 toBus.MoveSignal( toInput, signal );
-
545 }
-
546 else if ( ++ref.count != ref.total )
-
547 {
-
548 // this is not the final reference, copy the signal
-
549 toBus.SetSignal( toInput, signal );
-
550 }
-
551 else
-
552 {
-
553 // this is the final reference, reset the counter, move the signal
-
554 ref.count = 0;
-
555 toBus.MoveSignal( toInput, signal );
-
556 }
-
557}
-
558
-
559inline void Component::_GetOutputParallel( int bufferNo, int fromOutput, int toInput, DSPatch::SignalBus& toBus )
-
560{
-
561 auto& signal = *_outputBuses[bufferNo].GetSignal( fromOutput );
-
562 auto& ref = _refs[bufferNo][fromOutput];
-
563
-
564 // wait for this output to be ready
-
565 ref.readyFlag.WaitAndClear();
-
566
-
567 if ( !signal.has_value() )
-
568 {
-
569 return;
-
570 }
-
571
-
572 if ( ref.total == 1 )
-
573 {
-
574 // there's only one reference, move the signal immediately and return
-
575 toBus.MoveSignal( toInput, signal );
-
576 }
-
577 else if ( ++ref.count != ref.total )
-
578 {
-
579 // this is not the final reference, copy the signal
-
580 toBus.SetSignal( toInput, signal );
-
581
-
582 // wake next WaitAndClear()
-
583 ref.readyFlag.Set();
-
584 }
-
585 else
-
586 {
-
587 // this is the final reference, reset the counter, move the signal
-
588 ref.count = 0;
-
589 toBus.MoveSignal( toInput, signal );
-
590 }
-
591}
-
592
-
593inline void Component::_IncRefs( int output )
-
594{
-
595 for ( auto& ref : _refs )
-
596 {
-
597 ++ref[output].total;
-
598 }
-
599}
-
600
-
601inline void Component::_DecRefs( int output )
-
602{
-
603 for ( auto& ref : _refs )
-
604 {
-
605 --ref[output].total;
-
606 }
-
607}
-
608
-
609} // namespace DSPatch
+
539inline void Component::_GetOutput( int bufferNo, int fromOutput, int toInput, DSPatch::SignalBus& toBus )
+
540{
+
541 auto& signal = *_outputBuses[bufferNo].GetSignal( fromOutput );
+
542
+
543 if ( !signal.has_value() )
+
544 {
+
545 return;
+
546 }
+
547
+
548 auto& ref = _refs[bufferNo][fromOutput];
+
549
+
550 if ( ref.total == 1 )
+
551 {
+
552 // there's only one reference, move the signal immediately
+
553 toBus.MoveSignal( toInput, signal );
+
554 }
+
555 else if ( ++ref.count != ref.total )
+
556 {
+
557 // this is not the final reference, copy the signal
+
558 toBus.SetSignal( toInput, signal );
+
559 }
+
560 else
+
561 {
+
562 // this is the final reference, reset the counter, move the signal
+
563 ref.count = 0;
+
564 toBus.MoveSignal( toInput, signal );
+
565 }
+
566}
+
567
+
568inline void Component::_GetOutputParallel( int bufferNo, int fromOutput, int toInput, DSPatch::SignalBus& toBus )
+
569{
+
570 auto& signal = *_outputBuses[bufferNo].GetSignal( fromOutput );
+
571 auto& ref = _refs[bufferNo][fromOutput];
+
572
+
573 // wait for this output to be ready
+
574 ref.readyFlag.WaitAndClear();
+
575
+
576 if ( !signal.has_value() )
+
577 {
+
578 return;
+
579 }
+
580
+
581 if ( ref.total == 1 )
+
582 {
+
583 // there's only one reference, move the signal immediately and return
+
584 toBus.MoveSignal( toInput, signal );
+
585 }
+
586 else if ( ++ref.count != ref.total )
+
587 {
+
588 // this is not the final reference, copy the signal
+
589 toBus.SetSignal( toInput, signal );
+
590
+
591 // wake next WaitAndClear()
+
592 ref.readyFlag.Set();
+
593 }
+
594 else
+
595 {
+
596 // this is the final reference, reset the counter, move the signal
+
597 ref.count = 0;
+
598 toBus.MoveSignal( toInput, signal );
+
599 }
+
600}
+
601
+
602inline void Component::_IncRefs( int output )
+
603{
+
604 for ( auto& ref : _refs )
+
605 {
+
606 ++ref[output].total;
+
607 }
+
608}
+
609
+
610inline void Component::_DecRefs( int output )
+
611{
+
612 for ( auto& ref : _refs )
+
613 {
+
614 --ref[output].total;
+
615 }
+
616}
+
617
+
618} // namespace DSPatch
Abstract base class for DSPatch components.
Definition Component.h:65
Signal container.
Definition SignalBus.h:53
diff --git a/docs/html/_d_s_patch_8h_source.html b/docs/html/_d_s_patch_8h_source.html index 9b59c44b..3a3b8091 100644 --- a/docs/html/_d_s_patch_8h_source.html +++ b/docs/html/_d_s_patch_8h_source.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
diff --git a/docs/html/_plugin_8h_source.html b/docs/html/_plugin_8h_source.html index ebae23e0..acf75e42 100644 --- a/docs/html/_plugin_8h_source.html +++ b/docs/html/_plugin_8h_source.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
diff --git a/docs/html/_signal_bus_8h_source.html b/docs/html/_signal_bus_8h_source.html index ac053801..344ed75c 100644 --- a/docs/html/_signal_bus_8h_source.html +++ b/docs/html/_signal_bus_8h_source.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
diff --git a/docs/html/annotated.html b/docs/html/annotated.html index 65c65a07..147d98ee 100644 --- a/docs/html/annotated.html +++ b/docs/html/annotated.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
diff --git a/docs/html/class_d_s_patch_1_1_circuit-members.html b/docs/html/class_d_s_patch_1_1_circuit-members.html index 6c677c64..7625caa7 100644 --- a/docs/html/class_d_s_patch_1_1_circuit-members.html +++ b/docs/html/class_d_s_patch_1_1_circuit-members.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
diff --git a/docs/html/class_d_s_patch_1_1_circuit.html b/docs/html/class_d_s_patch_1_1_circuit.html index 6bee66b2..b3c77b7e 100644 --- a/docs/html/class_d_s_patch_1_1_circuit.html +++ b/docs/html/class_d_s_patch_1_1_circuit.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
diff --git a/docs/html/class_d_s_patch_1_1_component-members.html b/docs/html/class_d_s_patch_1_1_component-members.html index c876f17c..35b87969 100644 --- a/docs/html/class_d_s_patch_1_1_component-members.html +++ b/docs/html/class_d_s_patch_1_1_component-members.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
diff --git a/docs/html/class_d_s_patch_1_1_component.html b/docs/html/class_d_s_patch_1_1_component.html index 6f400484..6d686b38 100644 --- a/docs/html/class_d_s_patch_1_1_component.html +++ b/docs/html/class_d_s_patch_1_1_component.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
@@ -297,7 +297,7 @@

-

Definition at line 255 of file Component.h.

+

Definition at line 260 of file Component.h.

@@ -325,7 +325,7 @@

-

Definition at line 240 of file Component.h.

+

Definition at line 245 of file Component.h.

@@ -353,7 +353,7 @@

-

Definition at line 226 of file Component.h.

+

Definition at line 231 of file Component.h.

@@ -380,7 +380,7 @@

-

Definition at line 479 of file Component.h.

+

Definition at line 488 of file Component.h.

@@ -407,7 +407,7 @@

-

Definition at line 346 of file Component.h.

+

Definition at line 354 of file Component.h.

@@ -434,7 +434,7 @@

-

Definition at line 267 of file Component.h.

+

Definition at line 272 of file Component.h.

@@ -462,7 +462,7 @@

-

Definition at line 278 of file Component.h.

+

Definition at line 283 of file Component.h.

@@ -489,7 +489,7 @@

-

Definition at line 272 of file Component.h.

+

Definition at line 277 of file Component.h.

@@ -517,7 +517,7 @@

-

Definition at line 288 of file Component.h.

+

Definition at line 293 of file Component.h.

@@ -555,7 +555,7 @@

-

Definition at line 449 of file Component.h.

+

Definition at line 457 of file Component.h.

@@ -583,7 +583,7 @@

-

Definition at line 429 of file Component.h.

+

Definition at line 437 of file Component.h.

@@ -621,7 +621,7 @@

-

Definition at line 297 of file Component.h.

+

Definition at line 302 of file Component.h.

@@ -659,7 +659,7 @@

-

Definition at line 485 of file Component.h.

+

Definition at line 494 of file Component.h.

@@ -697,7 +697,7 @@

-

Definition at line 497 of file Component.h.

+

Definition at line 506 of file Component.h.

@@ -725,7 +725,7 @@

-

Definition at line 386 of file Component.h.

+

Definition at line 394 of file Component.h.

@@ -753,7 +753,7 @@

-

Definition at line 351 of file Component.h.

+

Definition at line 359 of file Component.h.

diff --git a/docs/html/class_d_s_patch_1_1_plugin-members.html b/docs/html/class_d_s_patch_1_1_plugin-members.html index 7ed60d08..93de3e66 100644 --- a/docs/html/class_d_s_patch_1_1_plugin-members.html +++ b/docs/html/class_d_s_patch_1_1_plugin-members.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
diff --git a/docs/html/class_d_s_patch_1_1_plugin.html b/docs/html/class_d_s_patch_1_1_plugin.html index 721a07e9..26554272 100644 --- a/docs/html/class_d_s_patch_1_1_plugin.html +++ b/docs/html/class_d_s_patch_1_1_plugin.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
diff --git a/docs/html/class_d_s_patch_1_1_signal_bus-members.html b/docs/html/class_d_s_patch_1_1_signal_bus-members.html index 03a50250..2b03e9fd 100644 --- a/docs/html/class_d_s_patch_1_1_signal_bus-members.html +++ b/docs/html/class_d_s_patch_1_1_signal_bus-members.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
diff --git a/docs/html/class_d_s_patch_1_1_signal_bus.html b/docs/html/class_d_s_patch_1_1_signal_bus.html index e07d91c6..21f5c02e 100644 --- a/docs/html/class_d_s_patch_1_1_signal_bus.html +++ b/docs/html/class_d_s_patch_1_1_signal_bus.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
diff --git a/docs/html/classes.html b/docs/html/classes.html index 1306eace..a6cf3073 100644 --- a/docs/html/classes.html +++ b/docs/html/classes.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
diff --git a/docs/html/dir_96ae4afe4ae1b3c2e5b248f6fc6b60cd.html b/docs/html/dir_96ae4afe4ae1b3c2e5b248f6fc6b60cd.html index ef269298..9116d05b 100644 --- a/docs/html/dir_96ae4afe4ae1b3c2e5b248f6fc6b60cd.html +++ b/docs/html/dir_96ae4afe4ae1b3c2e5b248f6fc6b60cd.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
diff --git a/docs/html/dir_d44c64559bbebec7f509842c48db8b23.html b/docs/html/dir_d44c64559bbebec7f509842c48db8b23.html index 626cd1d7..817ca901 100644 --- a/docs/html/dir_d44c64559bbebec7f509842c48db8b23.html +++ b/docs/html/dir_d44c64559bbebec7f509842c48db8b23.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
diff --git a/docs/html/files.html b/docs/html/files.html index 396907da..c570474d 100644 --- a/docs/html/files.html +++ b/docs/html/files.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3
diff --git a/docs/html/index.html b/docs/html/index.html index f4f2e3f2..cdfd1665 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -22,7 +22,7 @@ Logo -
DSPatch v.11.1.2 +
DSPatch v.11.1.3