Skip to content

Commit

Permalink
_ReleaseNextThread() -> _ReleaseNextBuffer()
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusTomlinson committed Apr 5, 2024
1 parent 764db52 commit 4c658ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
9 changes: 4 additions & 5 deletions include/dspatch/Circuit.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,10 @@ class Circuit final
{
// You might be thinking: Can't we have each thread start on a different component?

// Well no. Because bufferNo == bufferNo, in order to maintain synchronisation
// within the circuit, when a component wants to process its buffers in-order, it
// requires that every other in-order component in the system has not only
// processed its buffers in the same order, but has processed the same number of
// buffers too.
// Well no. In order to maintain synchronisation within the circuit, when a component
// wants to process its buffers in-order, it requires that every other in-order
// component in the system has not only processed its buffers in the same order, but
// has processed the same number of buffers too.

// E.g. 1,2,3 and 1,2,3. Not 1,2,3 and 2,3,1,2,3.

Expand Down
18 changes: 9 additions & 9 deletions include/dspatch/Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ class Component
int toInput;
};

void _WaitForRelease( int threadNo );
void _ReleaseNextThread( int threadNo );
void _WaitForRelease( int bufferNo );
void _ReleaseNextBuffer( int bufferNo );

void _GetOutput( int bufferNo, int fromOutput, int toInput, DSPatch::SignalBus& toBus );
void _GetOutputParallel( int bufferNo, int fromOutput, int toInput, DSPatch::SignalBus& toBus );
Expand Down Expand Up @@ -382,7 +382,7 @@ inline void Component::TickSeries( int bufferNo )
Process_( inputBus, outputBus );

// signal that we're done processing
_ReleaseNextThread( bufferNo );
_ReleaseNextBuffer( bufferNo );
}
else
{
Expand Down Expand Up @@ -415,7 +415,7 @@ inline void Component::TickParallel( int bufferNo )
Process_( inputBus, outputBus );

// signal that we're done processing
_ReleaseNextThread( bufferNo );
_ReleaseNextBuffer( bufferNo );
}
else
{
Expand Down Expand Up @@ -519,20 +519,20 @@ inline void Component::SetOutputCount_( int outputCount, const std::vector<std::
}
}

inline void Component::_WaitForRelease( int threadNo )
inline void Component::_WaitForRelease( int bufferNo )
{
_releaseFlags[threadNo].WaitAndClear();
_releaseFlags[bufferNo].WaitAndClear();
}

inline void Component::_ReleaseNextThread( int threadNo )
inline void Component::_ReleaseNextBuffer( int bufferNo )
{
if ( ++threadNo == _bufferCount ) // we're actually releasing the next available thread
if ( ++bufferNo == _bufferCount ) // release the next available buffer
{
_releaseFlags[0].Set();
}
else
{
_releaseFlags[threadNo].Set();
_releaseFlags[bufferNo].Set();
}
}

Expand Down

0 comments on commit 4c658ae

Please sign in to comment.