From 4266af545a0399776abe107bc1079cd560dd25ea Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Sat, 30 May 2026 11:59:42 -0400 Subject: [PATCH] Boost.ASIO: upgrade io_service=>io_context, finally --- .../attachmentSupport/stimulusProducer.cpp | 2 +- commonLibs/livoxProto1/broadcastListener.cpp | 2 +- commonLibs/livoxProto1/device.cpp | 2 +- commonLibs/livoxProto1/protocol.h | 2 +- commonLibs/livoxProto1/udpCommandDemuxer.cpp | 18 +++++++------- .../adapters/boostAsio/deadlineTimerAReq.h | 20 ++++++++-------- include/adapters/smo/cpsCallbackAReq.h | 10 ++++---- include/user/senseApiDesc.h | 2 +- include/user/stimulusProducer.h | 10 ++++---- libspinscale | 2 +- main.cpp | 5 ++-- smocore/componentThreadTags.cpp | 24 +++++++++---------- smocore/deviceManager/deviceReattacher.cpp | 2 +- smocore/include/body/bodyThread.h | 4 ++-- smocore/include/director/directorThread.h | 4 ++-- smocore/include/marionette/marionetteThread.h | 4 ++-- smocore/include/simulator/simulatorThread.h | 4 ++-- smocore/include/subconsciousThread.h | 4 ++-- smocore/include/world/worldThread.h | 4 ++-- smocore/marionette/lifetime.cpp | 2 +- smocore/marionette/main.cpp | 2 +- .../livoxGen1/ioUringAssemblyEngine.cpp | 18 +++++++------- .../livoxGen1/ioUringAssemblyEngine.h | 2 +- stimBuffApis/livoxGen1/livoxGen1.cpp | 8 +++---- .../openClCollatingAndMeshingEngine.cpp | 20 ++++++++-------- .../livoxGen1/pcloudStimulusProducer.cpp | 4 ++-- 26 files changed, 91 insertions(+), 90 deletions(-) diff --git a/commonLibs/attachmentSupport/stimulusProducer.cpp b/commonLibs/attachmentSupport/stimulusProducer.cpp index ae38126..aa819d5 100644 --- a/commonLibs/attachmentSupport/stimulusProducer.cpp +++ b/commonLibs/attachmentSupport/stimulusProducer.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/commonLibs/livoxProto1/broadcastListener.cpp b/commonLibs/livoxProto1/broadcastListener.cpp index 61993eb..a8078ea 100644 --- a/commonLibs/livoxProto1/broadcastListener.cpp +++ b/commonLibs/livoxProto1/broadcastListener.cpp @@ -19,7 +19,7 @@ BroadcastListener::BroadcastListener( listeningPort(listeningPort), connectPort(connectPort), deviceGoneAwayCb(nullptr), -socket(componentThread->getIoService()), +socket(componentThread->getIoContext()), listeningEndpoint(boost::asio::ip::udp::v4(), listeningPort), isListening(false) { diff --git a/commonLibs/livoxProto1/device.cpp b/commonLibs/livoxProto1/device.cpp index 26757dc..bc1acde 100644 --- a/commonLibs/livoxProto1/device.cpp +++ b/commonLibs/livoxProto1/device.cpp @@ -1098,7 +1098,7 @@ void Device::startHeartbeat() // Create heartbeat timer heartbeatTimer = std::make_unique( - componentThread->getIoService()); + componentThread->getIoContext()); heartbeatActive.store(true); diff --git a/commonLibs/livoxProto1/protocol.h b/commonLibs/livoxProto1/protocol.h index ae51437..8636f72 100644 --- a/commonLibs/livoxProto1/protocol.h +++ b/commonLibs/livoxProto1/protocol.h @@ -35,7 +35,7 @@ namespace endian { // IPv4 address validation inline bool isValidIPv4(const std::string& ipAddress) { boost::system::error_code ec; - boost::asio::ip::address_v4::from_string(ipAddress, ec); + (void)boost::asio::ip::make_address_v4(ipAddress, ec); return !ec; } diff --git a/commonLibs/livoxProto1/udpCommandDemuxer.cpp b/commonLibs/livoxProto1/udpCommandDemuxer.cpp index 011360c..b49b24b 100644 --- a/commonLibs/livoxProto1/udpCommandDemuxer.cpp +++ b/commonLibs/livoxProto1/udpCommandDemuxer.cpp @@ -213,7 +213,7 @@ void UdpCommandDemuxer::setupCommandSocket() // Create boost wrapper for async operations cmdEndpointFdDesc = std::make_shared( - componentThread->getIoService(), socketGuard.getFd()); + componentThread->getIoContext(), socketGuard.getFd()); // Transfer ownership, prevent auto-close socketGuard.commit(); @@ -269,7 +269,7 @@ void UdpCommandDemuxer::setupPcloudDataSocket() // Create boost wrapper for async operations pcloudDataFdDesc = std::make_shared( - componentThread->getIoService(), socketGuard.getFd()); + componentThread->getIoContext(), socketGuard.getFd()); // Transfer ownership, prevent auto-close socketGuard.commit(); @@ -419,16 +419,16 @@ void UdpCommandDemuxer::processIncomingData() struct UdpCommandDemuxer::PendingCommandWaitDesc { CommandWaitKey key; - boost::asio::io_service &resumeIoService; + boost::asio::io_context &resumeIoContext; std::atomic settled{false}; UdpCommandResponseResult result{}; std::coroutine_handle<> callerSchedHandle; PendingCommandWaitDesc( CommandWaitKey keyIn, - boost::asio::io_service &resumeIoServiceIn) + boost::asio::io_context &resumeIoContextIn) : key(std::move(keyIn)), - resumeIoService(resumeIoServiceIn) + resumeIoContext(resumeIoContextIn) {} }; @@ -458,7 +458,7 @@ void UdpCommandDemuxer::settlePendingCommandWait( return; } - boost::asio::post(wait->resumeIoService, handle); + boost::asio::post(wait->resumeIoContext, handle); } std::shared_ptr @@ -518,7 +518,7 @@ UdpCommandDemuxer::waitForCommandResponseCReq( { const CommandWaitKey key{deviceIp, cmdSet, cmdId}; auto wait = std::make_shared( - key, componentThread->getIoService()); + key, componentThread->getIoContext()); { sscl::SpinLock::Guard guard(pendingWaits.lock); @@ -577,10 +577,10 @@ UdpCommandDemuxer::waitForCommandResponseCReq( * request. If the device does not respond within the timeout period, * we will consider the command to have failed. */ - boost::asio::io_service &ioService = componentThread->getIoService(); + boost::asio::io_context &ioContext = componentThread->getIoContext(); std::optional> raceTimer; auto timerAwaiter = adapters::boostAsio::getDeadlineTimerAReqAwaiter( - ioService, + ioContext, boost::posix_time::milliseconds(timeoutMs), raceTimer); auto responseInvoker = waitForCommandResponseCReq(cmdSet, cmdId, deviceIp); diff --git a/include/adapters/boostAsio/deadlineTimerAReq.h b/include/adapters/boostAsio/deadlineTimerAReq.h index b7096f2..163b805 100644 --- a/include/adapters/boostAsio/deadlineTimerAReq.h +++ b/include/adapters/boostAsio/deadlineTimerAReq.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -29,14 +29,14 @@ public: }; DeadlineTimerAReq( - boost::asio::io_service &resumeIoService, + boost::asio::io_context &resumeIoContext, const boost::posix_time::milliseconds delay, std::optional> &timerOut) : asyncState(std::make_shared()), - resumeIoService(resumeIoService) + resumeIoContext(resumeIoContext) { asyncState->timer = - std::make_shared(resumeIoService); + std::make_shared(resumeIoContext); timerOut = asyncState->timer; asyncState->timer->expires_from_now(delay); @@ -85,27 +85,27 @@ private: return; } - boost::asio::post(resumeIoService, handle); + boost::asio::post(resumeIoContext, handle); } std::shared_ptr asyncState; - boost::asio::io_service &resumeIoService; + boost::asio::io_context &resumeIoContext; }; inline auto getDeadlineTimerAReqAwaiter( - boost::asio::io_service &ioService, + boost::asio::io_context &ioContext, const boost::posix_time::milliseconds delay) { std::optional> timerOut; - return DeadlineTimerAReq(ioService, delay, timerOut); + return DeadlineTimerAReq(ioContext, delay, timerOut); } inline auto getDeadlineTimerAReqAwaiter( - boost::asio::io_service &ioService, + boost::asio::io_context &ioContext, const boost::posix_time::milliseconds delay, std::optional> &timerOut) { - return DeadlineTimerAReq(ioService, delay, timerOut); + return DeadlineTimerAReq(ioContext, delay, timerOut); } } // namespace adapters::boostAsio diff --git a/include/adapters/smo/cpsCallbackAReq.h b/include/adapters/smo/cpsCallbackAReq.h index 5e90ad6..46bba8b 100644 --- a/include/adapters/smo/cpsCallbackAReq.h +++ b/include/adapters/smo/cpsCallbackAReq.h @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include @@ -30,10 +30,10 @@ public: }; CpsCallbackAReq( - boost::asio::io_service &resumeIoService, + boost::asio::io_context &resumeIoContext, StartFn startFn) : asyncState(std::make_shared()), - resumeIoService(resumeIoService) + resumeIoContext(resumeIoContext) { startFn(sscl::cps::Callback{ nullptr, @@ -80,11 +80,11 @@ private: return; } - boost::asio::post(resumeIoService, handle); + boost::asio::post(resumeIoContext, handle); } std::shared_ptr asyncState; - boost::asio::io_service &resumeIoService; + boost::asio::io_context &resumeIoContext; }; } // namespace cpsBoundary diff --git a/include/user/senseApiDesc.h b/include/user/senseApiDesc.h index ff25586..f3bd864 100644 --- a/include/user/senseApiDesc.h +++ b/include/user/senseApiDesc.h @@ -228,7 +228,7 @@ public: * The SmoCallbacks parameter provides the library with access to * Salmanoff's hooks. * The SmoThreadingModelDesc parameter provides the library with access to - * the io_service for network operations and event handling. + * the io_context for network operations and event handling. */ typedef const StimBuffApiDesc &(SMO_GET_STIM_BUFF_API_DESC_FN_TYPEDEF)( const SmoCallbacks& callbacks, diff --git a/include/user/stimulusProducer.h b/include/user/stimulusProducer.h index dab5cee..5fd3cac 100644 --- a/include/user/stimulusProducer.h +++ b/include/user/stimulusProducer.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -39,10 +39,10 @@ public: explicit StimulusProducer( const std::shared_ptr &deviceAttachmentSpec, - boost::asio::io_service& ioService_) + boost::asio::io_context& ioContext_) : deviceAttachmentSpec(deviceAttachmentSpec), - ioService(ioService_), - timer(ioService), nDeferrals(0) + ioContext(ioContext_), + timer(ioContext), nDeferrals(0) {} virtual ~StimulusProducer() = default; @@ -107,7 +107,7 @@ public: std::vector> attachedStimulusBuffers; private: - boost::asio::io_service& ioService; + boost::asio::io_context& ioContext; protected: sscl::SyncCancelerForAsyncWork stimulusProducerCanceler; private: diff --git a/libspinscale b/libspinscale index 0afa3e1..3ea1475 160000 --- a/libspinscale +++ b/libspinscale @@ -1 +1 @@ -Subproject commit 0afa3e16b80ee96a465fc364c1063c23a9655ee6 +Subproject commit 3ea1475757af398a45948ea5181cdc2be2a011db diff --git a/main.cpp b/main.cpp index c9055c1..9834d81 100644 --- a/main.cpp +++ b/main.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -18,13 +19,13 @@ int main(int argc, char *argv[], char *envp[]) */ std::cout << "CRT:" << __func__ << ": about to JOLT Mrntt with cmdline args" << '\n'; - smo::mrntt::thread->getIoService().post( + boost::asio::post(smo::mrntt::thread->getIoContext(), [argc, argv, envp]() { std::cout << "Mrntt:" << __func__ << ":JOLTED: setting cmdline args" << '\n'; sscl::CrtCommandLineArgs::set(argc, argv, envp); - smo::mrntt::thread->getIoService().stop(); + smo::mrntt::thread->getIoContext().stop(); } ); diff --git a/smocore/componentThreadTags.cpp b/smocore/componentThreadTags.cpp index 20b4771..3a2f499 100644 --- a/smocore/componentThreadTags.cpp +++ b/smocore/componentThreadTags.cpp @@ -13,73 +13,73 @@ namespace smo { namespace mrntt { -boost::asio::io_service &MrnttThreadTag::io_service() noexcept +boost::asio::io_context &MrnttThreadTag::io_context() noexcept { - return thread->getIoService(); + return thread->getIoContext(); } } // namespace mrntt namespace body { -boost::asio::io_service &BodyThreadTag::io_service() +boost::asio::io_context &BodyThreadTag::io_context() { if (!mind::globalMind) { throw std::runtime_error( "BodyThreadTag: globalMind not initialized"); } - return mind::globalMind->body.thread->getIoService(); + return mind::globalMind->body.thread->getIoContext(); } } // namespace body namespace director { -boost::asio::io_service &DirectorThreadTag::io_service() +boost::asio::io_context &DirectorThreadTag::io_context() { if (!mind::globalMind) { throw std::runtime_error( "DirectorThreadTag: globalMind not initialized"); } - return mind::globalMind->director.thread->getIoService(); + return mind::globalMind->director.thread->getIoContext(); } } // namespace director namespace simulator { -boost::asio::io_service &SimulatorThreadTag::io_service() +boost::asio::io_context &SimulatorThreadTag::io_context() { if (!mind::globalMind) { throw std::runtime_error( "SimulatorThreadTag: globalMind not initialized"); } - return mind::globalMind->canvas.thread->getIoService(); + return mind::globalMind->canvas.thread->getIoContext(); } } // namespace simulator -boost::asio::io_service &SubconsciousThreadTag::io_service() +boost::asio::io_context &SubconsciousThreadTag::io_context() { if (!mind::globalMind) { throw std::runtime_error( "SubconsciousThreadTag: globalMind not initialized"); } - return mind::globalMind->subconscious.thread->getIoService(); + return mind::globalMind->subconscious.thread->getIoContext(); } -boost::asio::io_service &WorldThreadTag::io_service() +boost::asio::io_context &WorldThreadTag::io_context() { if (!mind::globalMind) { throw std::runtime_error( "WorldThreadTag: globalMind not initialized"); } - return mind::globalMind->world.thread->getIoService(); + return mind::globalMind->world.thread->getIoContext(); } } // namespace smo diff --git a/smocore/deviceManager/deviceReattacher.cpp b/smocore/deviceManager/deviceReattacher.cpp index d5eff81..9c75a27 100644 --- a/smocore/deviceManager/deviceReattacher.cpp +++ b/smocore/deviceManager/deviceReattacher.cpp @@ -18,7 +18,7 @@ constexpr unsigned int reattachInFlightStaleThresholdMultiplier = 4; DeviceReattacher::DeviceReattacher( DeviceManager& parent, std::shared_ptr ioThread) -: parent(parent), ioThread(ioThread), timer(ioThread->getIoService()) +: parent(parent), ioThread(ioThread), timer(ioThread->getIoContext()) { } diff --git a/smocore/include/body/bodyThread.h b/smocore/include/body/bodyThread.h index 42b2b5e..b667755 100644 --- a/smocore/include/body/bodyThread.h +++ b/smocore/include/body/bodyThread.h @@ -1,7 +1,7 @@ #ifndef SMO_BODY_THREAD_H #define SMO_BODY_THREAD_H -#include +#include #include #include @@ -10,7 +10,7 @@ namespace body { struct BodyThreadTag { - static boost::asio::io_service &io_service(); + static boost::asio::io_context &io_context(); }; template diff --git a/smocore/include/director/directorThread.h b/smocore/include/director/directorThread.h index a4f8ddd..acaa582 100644 --- a/smocore/include/director/directorThread.h +++ b/smocore/include/director/directorThread.h @@ -1,7 +1,7 @@ #ifndef SMO_DIRECTOR_THREAD_H #define SMO_DIRECTOR_THREAD_H -#include +#include #include #include @@ -10,7 +10,7 @@ namespace director { struct DirectorThreadTag { - static boost::asio::io_service &io_service(); + static boost::asio::io_context &io_context(); }; template diff --git a/smocore/include/marionette/marionetteThread.h b/smocore/include/marionette/marionetteThread.h index 845175e..109dfce 100644 --- a/smocore/include/marionette/marionetteThread.h +++ b/smocore/include/marionette/marionetteThread.h @@ -1,7 +1,7 @@ #ifndef SMO_MARIONETTE_THREAD_H #define SMO_MARIONETTE_THREAD_H -#include +#include #include #include @@ -10,7 +10,7 @@ namespace mrntt { struct MrnttThreadTag { - static boost::asio::io_service &io_service() noexcept; + static boost::asio::io_context &io_context() noexcept; }; template diff --git a/smocore/include/simulator/simulatorThread.h b/smocore/include/simulator/simulatorThread.h index d091730..1bc4e56 100644 --- a/smocore/include/simulator/simulatorThread.h +++ b/smocore/include/simulator/simulatorThread.h @@ -1,7 +1,7 @@ #ifndef SMO_SIMULATOR_THREAD_H #define SMO_SIMULATOR_THREAD_H -#include +#include #include #include @@ -10,7 +10,7 @@ namespace simulator { struct SimulatorThreadTag { - static boost::asio::io_service &io_service(); + static boost::asio::io_context &io_context(); }; template diff --git a/smocore/include/subconsciousThread.h b/smocore/include/subconsciousThread.h index 01059f4..0818937 100644 --- a/smocore/include/subconsciousThread.h +++ b/smocore/include/subconsciousThread.h @@ -1,7 +1,7 @@ #ifndef SMO_SUBCONSCIOUS_THREAD_H #define SMO_SUBCONSCIOUS_THREAD_H -#include +#include #include #include @@ -9,7 +9,7 @@ namespace smo { struct SubconsciousThreadTag { - static boost::asio::io_service &io_service(); + static boost::asio::io_context &io_context(); }; template diff --git a/smocore/include/world/worldThread.h b/smocore/include/world/worldThread.h index dfc8313..8eaa878 100644 --- a/smocore/include/world/worldThread.h +++ b/smocore/include/world/worldThread.h @@ -1,7 +1,7 @@ #ifndef SMO_WORLD_THREAD_H #define SMO_WORLD_THREAD_H -#include +#include #include #include @@ -9,7 +9,7 @@ namespace smo { struct WorldThreadTag { - static boost::asio::io_service &io_service(); + static boost::asio::io_context &io_context(); }; template diff --git a/smocore/marionette/lifetime.cpp b/smocore/marionette/lifetime.cpp index 4750c11..8f6befe 100644 --- a/smocore/marionette/lifetime.cpp +++ b/smocore/marionette/lifetime.cpp @@ -103,7 +103,7 @@ void MarionetteComponent::exceptionInd() auto puppeteer = sscl::ComponentThread::getPptr(); boost::asio::post( - puppeteer->getIoService(), + puppeteer->getIoContext(), [] { mrntt.holdFinalizeCReq( diff --git a/smocore/marionette/main.cpp b/smocore/marionette/main.cpp index fdecc18..f5dea69 100644 --- a/smocore/marionette/main.cpp +++ b/smocore/marionette/main.cpp @@ -63,7 +63,7 @@ void MarionetteComponent::postJoltHook() // Register SIGINT (Ctrl+C) and SIGSEGV handlers signals = std::make_unique( - th->getIoService(), SIGINT); + th->getIoContext(), SIGINT); signals->async_wait( [](const boost::system::error_code& ec, int signal) diff --git a/stimBuffApis/livoxGen1/ioUringAssemblyEngine.cpp b/stimBuffApis/livoxGen1/ioUringAssemblyEngine.cpp index f9c1bed..b477288 100644 --- a/stimBuffApis/livoxGen1/ioUringAssemblyEngine.cpp +++ b/stimBuffApis/livoxGen1/ioUringAssemblyEngine.cpp @@ -58,7 +58,7 @@ IoUringAssemblyEngine::IoUringAssemblyEngine( : parent(parent_), frameAssemblyDesc(nullptr), ring{}, eventfdFd(-1), eventfdDesc(nullptr), eventfd_value(0), -stallTimer(parent_.device->componentThread->getIoService()), +stallTimer(parent_.device->componentThread->getIoContext()), nDgramsPerStagingBufferFrame(nDgramsPerStagingBufferFrame_), assembledSlotsTracker(nDgramsPerStagingBufferFrame_), randomDevice(), randomGenerator(randomDevice()) @@ -170,9 +170,9 @@ void IoUringAssemblyEngine::finalize() bool wasAcceptingRequests = stop(); { - auto& ioService = smoHooksPtr->ComponentThread_getSelf()->getIoService(); - sscl::cps::AsynchronousBridge bridge(ioService); - boost::asio::deadline_timer timeoutTimer(ioService); + auto& ioContext = smoHooksPtr->ComponentThread_getSelf()->getIoContext(); + sscl::cps::AsynchronousBridge bridge(ioContext); + boost::asio::deadline_timer timeoutTimer(ioContext); /** EXPLANATION: * We wait for IOURINGASSM_ENGN_FRAME_ASSEM_TIMEOUT_MS + 1 ms to ensure @@ -196,7 +196,7 @@ void IoUringAssemblyEngine::finalize() bridge.setAsyncOperationComplete(); }); - bridge.waitForAsyncOperationCompleteOrIoServiceStopped(); + bridge.waitForAsyncOperationCompleteOrIoContextStopped(); } if (eventfdFd >= 0) @@ -265,7 +265,7 @@ void IoUringAssemblyEngine::resetAndAssembleFrame( } eventfdDesc = std::make_unique( - parent.device->componentThread->getIoService(), eventfdFd); + parent.device->componentThread->getIoContext(), eventfdFd); if (!eventfdDesc) { @@ -375,7 +375,7 @@ cleanup_eventfd: if (eventfdDesc) { /** EXPLANATION: - * The goal here is to ensure that our io_service's event loop will not + * The goal here is to ensure that our io_context's event loop will not * get any events from the eventfd after we've called * assemblyCycleComplete(). So we completely deinitialize the eventfd * descriptor. @@ -386,7 +386,7 @@ cleanup_eventfd: * is not closed. * * However, we need to close the descriptor's association with the - * io_service before releasing it, otherwise Boost.Asio will complain + * io_context before releasing it, otherwise Boost.Asio will complain * when we try to create a new descriptor with the same fd. */ /** CAVEAT: @@ -645,7 +645,7 @@ void IoUringAssemblyEngine::assembleFrameReq( auto request = std::make_shared( *this, caller, std::move(cb)); - parent.device->componentThread->getIoService().post( + boost::asio::post(parent.device->componentThread->getIoContext(), STC(std::bind( &AssembleFrameReq::assembleFrameReq1_posted, request.get(), request))); diff --git a/stimBuffApis/livoxGen1/ioUringAssemblyEngine.h b/stimBuffApis/livoxGen1/ioUringAssemblyEngine.h index 489997a..a339e9b 100644 --- a/stimBuffApis/livoxGen1/ioUringAssemblyEngine.h +++ b/stimBuffApis/livoxGen1/ioUringAssemblyEngine.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/stimBuffApis/livoxGen1/livoxGen1.cpp b/stimBuffApis/livoxGen1/livoxGen1.cpp index aafce3c..f05476f 100644 --- a/stimBuffApis/livoxGen1/livoxGen1.cpp +++ b/stimBuffApis/livoxGen1/livoxGen1.cpp @@ -355,9 +355,9 @@ attachByCreatingProducer( /* Delay here because getOrCreate just sent HandshakeReq, so device * may not yet be ready for another command. */ - // Initialize timer with LivoxGen1 metadata io_service + // Initialize timer with LivoxGen1 metadata io_context const bool delayOk = co_await adapters::boostAsio::getDeadlineTimerAReqAwaiter( - componentThread->getIoService(), + componentThread->getIoContext(), boost::posix_time::milliseconds(LIVOX_GEN1_DEVICE_COMMAND_DELAY_MS)); if (!delayOk) @@ -538,9 +538,9 @@ livoxGen1_detachDeviceCReq( // Add 5ms delay before destroying device // Helper method to delay and then call destroyDeviceReq - // Initialize timer with LivoxGen1 metadata io_service + // Initialize timer with LivoxGen1 metadata io_context co_await adapters::boostAsio::getDeadlineTimerAReqAwaiter( - requestComponentThread->getIoService(), + requestComponentThread->getIoContext(), boost::posix_time::milliseconds(LIVOX_GEN1_DEVICE_COMMAND_DELAY_MS)); // No other buffers - stop and remove StimProducer diff --git a/stimBuffApis/livoxGen1/openClCollatingAndMeshingEngine.cpp b/stimBuffApis/livoxGen1/openClCollatingAndMeshingEngine.cpp index a050d5d..9c32f8d 100644 --- a/stimBuffApis/livoxGen1/openClCollatingAndMeshingEngine.cpp +++ b/stimBuffApis/livoxGen1/openClCollatingAndMeshingEngine.cpp @@ -224,9 +224,9 @@ void OpenClCollatingAndMeshingEngine::finalize() */ int delayMs = std::max(OCLCOLLMESH_ENGN_FINALIZE_DELAY_MS, 0); - auto& ioService = smoHooksPtr->ComponentThread_getSelf()->getIoService(); - sscl::cps::AsynchronousBridge bridge(ioService); - boost::asio::deadline_timer timeoutTimer(ioService); + auto& ioContext = smoHooksPtr->ComponentThread_getSelf()->getIoContext(); + sscl::cps::AsynchronousBridge bridge(ioContext); + boost::asio::deadline_timer timeoutTimer(ioContext); /** EXPLANATION: * We wait for delayMs milliseconds to ensure that any in-flight OpenCL @@ -248,7 +248,7 @@ void OpenClCollatingAndMeshingEngine::finalize() bridge.setAsyncOperationComplete(); }); - bridge.waitForAsyncOperationCompleteOrIoServiceStopped(); + bridge.waitForAsyncOperationCompleteOrIoContextStopped(); } // Release OpenCL buffers via smo hooks @@ -317,10 +317,10 @@ void CL_CALLBACK OpenClCollatingAndMeshingEngine::compactKernelEventCallback( if (!engine || !engine->compactKernelCb) { return; } - // Post to io_service to call callback on the correct thread + // Post to io_context to call callback on the correct thread if (engine->parent.device && engine->parent.device->componentThread) { - engine->parent.device->componentThread->getIoService().post( + boost::asio::post(engine->parent.device->componentThread->getIoContext(), std::bind(engine->compactKernelCb, event_command_exec_status)); } } @@ -335,10 +335,10 @@ void CL_CALLBACK OpenClCollatingAndMeshingEngine::collateKernelEventCallback( if (!engine || !engine->collateKernelCb) { return; } - // Post to io_service to call callback on the correct thread + // Post to io_context to call callback on the correct thread if (engine->parent.device && engine->parent.device->componentThread) { - engine->parent.device->componentThread->getIoService().post( + boost::asio::post(engine->parent.device->componentThread->getIoContext(), std::bind(engine->collateKernelCb, event_command_exec_status)); } } @@ -1270,7 +1270,7 @@ void OpenClCollatingAndMeshingEngine::compactCollateAndMeshFrameReq( // Start with compaction if needed, then chain to collation if (needsCompaction) { - parent.device->componentThread->getIoService().post( + boost::asio::post(parent.device->componentThread->getIoContext(), STC(std::bind( &CompactCollateAndMeshFrameReq ::compactCollateAndMeshFrameReq1_doCompact_posted, @@ -1279,7 +1279,7 @@ void OpenClCollatingAndMeshingEngine::compactCollateAndMeshFrameReq( else { // Skip compaction, go straight to collation - parent.device->componentThread->getIoService().post( + boost::asio::post(parent.device->componentThread->getIoContext(), STC(std::bind( &CompactCollateAndMeshFrameReq ::compactCollateAndMeshFrameReq3_doCollate_posted, diff --git a/stimBuffApis/livoxGen1/pcloudStimulusProducer.cpp b/stimBuffApis/livoxGen1/pcloudStimulusProducer.cpp index e5d6075..b5e2e8e 100644 --- a/stimBuffApis/livoxGen1/pcloudStimulusProducer.cpp +++ b/stimBuffApis/livoxGen1/pcloudStimulusProducer.cpp @@ -114,7 +114,7 @@ PcloudStimulusProducer::PcloudStimulusProducer( size_t nDgramsPerStagingBufferFrame) : StimulusProducer( deviceAttachmentSpec, - device->componentThread->getIoService()), + device->componentThread->getIoContext()), nDgramsPerStagingBufferFrame(nDgramsPerStagingBufferFrame), device(device), formatDesc(formatDesc), @@ -764,7 +764,7 @@ void PcloudStimulusProducer::produceFrameReq( *this, caller, std::move(callback)); // Post the doAssemble method to the component thread - device->componentThread->getIoService().post( + boost::asio::post(device->componentThread->getIoContext(), STC(std::bind( &ProduceFrameReq::produceFrameReq1_doAssemble_posted, request.get(), request)));