StimBuff: customize stop() delay; add stimFrameProductionTimesliceInd
This commit is contained in:
@@ -54,7 +54,7 @@ public:
|
|||||||
shouldContinue(false), timer(ioService)
|
shouldContinue(false), timer(ioService)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~StimulusBuffer() = default;
|
virtual ~StimulusBuffer() = default;
|
||||||
|
|
||||||
// Non-copyable, movable
|
// Non-copyable, movable
|
||||||
StimulusBuffer(const StimulusBuffer&) = delete;
|
StimulusBuffer(const StimulusBuffer&) = delete;
|
||||||
@@ -71,6 +71,15 @@ public:
|
|||||||
|
|
||||||
void stop();
|
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:
|
private:
|
||||||
void onTimeout(const boost::system::error_code& error);
|
void onTimeout(const boost::system::error_code& error);
|
||||||
|
|
||||||
@@ -112,10 +121,9 @@ inline void StimulusBuffer::stop()
|
|||||||
boost::asio::deadline_timer delayTimer(ioService);
|
boost::asio::deadline_timer delayTimer(ioService);
|
||||||
AsynchronousBridge bridge(ioService);
|
AsynchronousBridge bridge(ioService);
|
||||||
|
|
||||||
// Set up the delay for CONFIG_STIMBUFF_FRAME_PERIOD_MS to let in-flight
|
// Set up the delay to let in-flight operation finish
|
||||||
// operation finish
|
|
||||||
delayTimer.expires_from_now(
|
delayTimer.expires_from_now(
|
||||||
boost::posix_time::milliseconds(CONFIG_STIMBUFF_FRAME_PERIOD_MS));
|
boost::posix_time::milliseconds(getStopDelayMs()));
|
||||||
|
|
||||||
delayTimer.async_wait(
|
delayTimer.async_wait(
|
||||||
[&bridge](const boost::system::error_code& error)
|
[&bridge](const boost::system::error_code& error)
|
||||||
@@ -166,7 +174,8 @@ inline void StimulusBuffer::onTimeout(const boost::system::error_code& error)
|
|||||||
else
|
else
|
||||||
{ nextWakeupDelayMs = CONFIG_STIMBUFF_FRAME_RETRY_DELAY_MS; }
|
{ 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
|
// Note: The lock should be released when frame production completes
|
||||||
|
|
||||||
// Schedule next timeout with the pre-determined duration
|
// Schedule next timeout with the pre-determined duration
|
||||||
|
|||||||
@@ -19,5 +19,11 @@ formatDesc(formatDesc), stagingBuffer(
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PcloudStimulusBuffer::stimFrameProductionTimesliceInd()
|
||||||
|
{
|
||||||
|
// Release the spinlock for now
|
||||||
|
frameAssemblyRateLimiter.release();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace stim_buff
|
} // namespace stim_buff
|
||||||
} // namespace smo
|
} // namespace smo
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ public:
|
|||||||
PcloudStimulusBuffer(PcloudStimulusBuffer&&) = default;
|
PcloudStimulusBuffer(PcloudStimulusBuffer&&) = default;
|
||||||
PcloudStimulusBuffer& operator=(PcloudStimulusBuffer&&) = default;
|
PcloudStimulusBuffer& operator=(PcloudStimulusBuffer&&) = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void stimFrameProductionTimesliceInd() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
device::DeviceAttachmentSpec deviceAttachmentSpec;
|
device::DeviceAttachmentSpec deviceAttachmentSpec;
|
||||||
std::shared_ptr<livoxProto1::Device> device;
|
std::shared_ptr<livoxProto1::Device> device;
|
||||||
|
|||||||
Reference in New Issue
Block a user