Formatting: move big inlines out of class def

This commit is contained in:
2025-10-31 13:47:00 -04:00
parent ebbb2b1345
commit 0de031c74b
+37 -29
View File
@@ -69,33 +69,10 @@ public:
scheduleNextTimeout(); scheduleNextTimeout();
} }
void stop() void stop();
{
shouldContinue.store(false);
// Set up a timeout bridge using the io_service private:
boost::asio::deadline_timer delayTimer(ioService); void onTimeout(const boost::system::error_code& error);
AsynchronousBridge bridge(ioService);
// Set up the delay for CONFIG_STIMBUFF_FRAME_PERIOD_MS to let in-flight
// operation finish
delayTimer.expires_from_now(
boost::posix_time::milliseconds(CONFIG_STIMBUFF_FRAME_PERIOD_MS));
delayTimer.async_wait(
[&bridge](const boost::system::error_code& error)
{
(void)error;
// Always signal complete, whether timeout expired or was cancelled
bridge.setAsyncOperationComplete();
});
bridge.waitForAsyncOperationCompleteOrIoServiceStopped();
// After delay, cancel timer and perform cleanup
timer.cancel();
}
public: public:
device::DeviceAttachmentSpec deviceAttachmentSpec; device::DeviceAttachmentSpec deviceAttachmentSpec;
@@ -122,9 +99,41 @@ private:
std::bind( std::bind(
&StimulusBuffer::onTimeout, this, std::placeholders::_1)); &StimulusBuffer::onTimeout, this, std::placeholders::_1));
} }
};
void onTimeout(const boost::system::error_code& error) /** Inline methods
******************************************************************************/
inline void StimulusBuffer::stop()
{
shouldContinue.store(false);
// Set up a timeout bridge using the io_service
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
delayTimer.expires_from_now(
boost::posix_time::milliseconds(CONFIG_STIMBUFF_FRAME_PERIOD_MS));
delayTimer.async_wait(
[&bridge](const boost::system::error_code& error)
{ {
(void)error;
// Always signal complete, whether timeout expired or was cancelled
bridge.setAsyncOperationComplete();
});
bridge.waitForAsyncOperationCompleteOrIoServiceStopped();
// After delay, cancel timer and perform cleanup
timer.cancel();
}
inline void StimulusBuffer::onTimeout(const boost::system::error_code& error)
{
// Timer was cancelled, which is expected when stopping // Timer was cancelled, which is expected when stopping
if (error == boost::asio::error::operation_aborted) { if (error == boost::asio::error::operation_aborted) {
return; return;
@@ -162,8 +171,7 @@ private:
// Schedule next timeout with the pre-determined duration // Schedule next timeout with the pre-determined duration
scheduleNextTimeout(nextWakeupDelayMs); scheduleNextTimeout(nextWakeupDelayMs);
} }
};
} // namespace stim_buff } // namespace stim_buff
} // namespace smo } // namespace smo