diff --git a/commonLibs/livoxProto1/udpCommandDemuxer.cpp b/commonLibs/livoxProto1/udpCommandDemuxer.cpp index 1bbe0f0..5f656d9 100644 --- a/commonLibs/livoxProto1/udpCommandDemuxer.cpp +++ b/commonLibs/livoxProto1/udpCommandDemuxer.cpp @@ -22,7 +22,6 @@ UdpCommandDemuxer::UdpCommandDemuxer( ) : componentThread(componentThread), deviceManager(deviceManager), commandPort(commandPort), -timer(componentThread->getIoService()), senderAddrLen(sizeof(senderAddr)) { } @@ -50,12 +49,6 @@ void UdpCommandDemuxer::start() // Start the async receive loop startAsyncReceive(); - // Start the timer for responsiveness to stop() - timer.expires_from_now(boost::posix_time::milliseconds(1000)); - timer.async_wait( - std::bind( - &UdpCommandDemuxer::onTimerTick, this, std::placeholders::_1)); - std::cout << __func__ << ": UDP Command Demuxer started on port " << commandPort << std::endl; @@ -77,9 +70,6 @@ void UdpCommandDemuxer::stop() shouldStop.store(true); - // Cancel timer - timer.cancel(); - // Close socket and cleanup if (cmdEndpointFdDesc) { @@ -198,31 +188,6 @@ void UdpCommandDemuxer::onDataReady(const boost::system::error_code &error) startAsyncReceive(); } -void UdpCommandDemuxer::onTimerTick(const boost::system::error_code &error) -{ - if (error == boost::asio::error::operation_aborted) - { return; } - - if (shouldStop.load()) - { - // Stop was called, cancel async operations and stop timer - if (cmdEndpointFdDesc) { - cmdEndpointFdDesc->cancel(); - } - timer.cancel(); - return; - } - - // Re-arm timer for next tick - if (isActive.load()) - { - timer.expires_from_now(boost::posix_time::milliseconds(1000)); - timer.async_wait( - std::bind( - &UdpCommandDemuxer::onTimerTick, this, std::placeholders::_1)); - } -} - void UdpCommandDemuxer::processIncomingData() { if (bytesReceived < 2) diff --git a/commonLibs/livoxProto1/udpCommandDemuxer.h b/commonLibs/livoxProto1/udpCommandDemuxer.h index 078f407..7f44b1c 100644 --- a/commonLibs/livoxProto1/udpCommandDemuxer.h +++ b/commonLibs/livoxProto1/udpCommandDemuxer.h @@ -3,7 +3,6 @@ #include #include -#include #include #include @@ -57,7 +56,6 @@ private: void setupSocket(); void startAsyncReceive(); void onDataReady(const boost::system::error_code& error); - void onTimerTick(const boost::system::error_code& error); void processIncomingData(); std::shared_ptr componentThread; @@ -66,7 +64,6 @@ private: // Socket and async objects std::shared_ptr cmdEndpointFdDesc; - boost::asio::deadline_timer timer; // State management std::atomic isActive{false};