StimulusBuffer: properly serialize timeslices
We previously unintentionally allowed multiple production operations to occur in the same timeslice because we were calling for production even when deferring timeslices.
This commit is contained in:
@@ -86,17 +86,22 @@ void StimulusBuffer::onTimeout(const boost::system::error_code& error)
|
||||
*/
|
||||
int nextWakeupDelayMs;
|
||||
if (frameAssemblyRateLimiter.tryAcquire())
|
||||
{ nextWakeupDelayMs = CONFIG_STIMBUFF_FRAME_PERIOD_MS; }
|
||||
else
|
||||
{
|
||||
nextWakeupDelayMs = CONFIG_STIMBUFF_FRAME_PERIOD_MS;
|
||||
|
||||
/** EXPLANATION:
|
||||
* Call the derived class's frame production handler
|
||||
* Note: The derived class's frame production handler (aka
|
||||
* its implementation of stimFrameProductionTimesliceInd()) must
|
||||
* release the lock when frame production completes
|
||||
*/
|
||||
stimFrameProductionTimesliceInd();
|
||||
}
|
||||
else {
|
||||
std::cout << __func__ << ": Deferring frame production due to rate limit." << std::endl;
|
||||
nextWakeupDelayMs = CONFIG_STIMBUFF_FRAME_RETRY_DELAY_MS;
|
||||
}
|
||||
|
||||
// Call the derived class's frame production handler
|
||||
stimFrameProductionTimesliceInd();
|
||||
// Note: The lock should be released when frame production completes
|
||||
|
||||
// Schedule next timeout with the pre-determined duration
|
||||
scheduleNextTimeout(nextWakeupDelayMs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user