StimBuff: customize stop() delay; add stimFrameProductionTimesliceInd
This commit is contained in:
@@ -54,7 +54,7 @@ public:
|
||||
shouldContinue(false), timer(ioService)
|
||||
{}
|
||||
|
||||
~StimulusBuffer() = default;
|
||||
virtual ~StimulusBuffer() = default;
|
||||
|
||||
// Non-copyable, movable
|
||||
StimulusBuffer(const StimulusBuffer&) = delete;
|
||||
@@ -71,6 +71,15 @@ public:
|
||||
|
||||
void stop();
|
||||
|
||||
protected:
|
||||
// Virtual functions for derived classes to override
|
||||
virtual int getStopDelayMs() const
|
||||
{
|
||||
return CONFIG_STIMBUFF_FRAME_PERIOD_MS;
|
||||
}
|
||||
|
||||
virtual void stimFrameProductionTimesliceInd() = 0;
|
||||
|
||||
private:
|
||||
void onTimeout(const boost::system::error_code& error);
|
||||
|
||||
@@ -112,10 +121,9 @@ inline void StimulusBuffer::stop()
|
||||
boost::asio::deadline_timer delayTimer(ioService);
|
||||
AsynchronousBridge bridge(ioService);
|
||||
|
||||
// Set up the delay for CONFIG_STIMBUFF_FRAME_PERIOD_MS to let in-flight
|
||||
// operation finish
|
||||
// Set up the delay to let in-flight operation finish
|
||||
delayTimer.expires_from_now(
|
||||
boost::posix_time::milliseconds(CONFIG_STIMBUFF_FRAME_PERIOD_MS));
|
||||
boost::posix_time::milliseconds(getStopDelayMs()));
|
||||
|
||||
delayTimer.async_wait(
|
||||
[&bridge](const boost::system::error_code& error)
|
||||
@@ -166,7 +174,8 @@ inline void StimulusBuffer::onTimeout(const boost::system::error_code& error)
|
||||
else
|
||||
{ nextWakeupDelayMs = CONFIG_STIMBUFF_FRAME_RETRY_DELAY_MS; }
|
||||
|
||||
// Placeholder handler (empty for now)
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user