From 6df9407e659a650a74f26eb1afb2e3ef4c0b3b99 Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Sat, 30 May 2026 11:57:57 -0400 Subject: [PATCH] Boost.ASIO: update io_service=>io_context --- CMakeLists.txt | 1 + include/spinscale/co/coConditionVariable.h | 18 ++++----- include/spinscale/co/coQutex.h | 8 ++-- include/spinscale/co/group.h | 6 +-- include/spinscale/co/postingPromise.h | 16 ++++---- include/spinscale/componentThread.h | 21 +++++----- include/spinscale/cps/asynchronousBridge.h | 25 ++++++------ .../spinscale/cps/asynchronousContinuation.h | 4 +- include/spinscale/cps/callableTracer.h | 4 +- include/spinscale/cps/lockSet.h | 2 +- include/spinscale/cps/lockerAndInvokerBase.h | 6 +-- .../cps/serializedAsynchronousContinuation.h | 38 ++++++++++++------- src/component.cpp | 14 +++---- src/componentThread.cpp | 32 ++++++++-------- src/puppeteerComponent.cpp | 16 ++++---- src/qutex.cpp | 6 +-- 16 files changed, 116 insertions(+), 101 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6172bf8..7397f34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,7 @@ find_package(Threads REQUIRED) # Create the library add_library(spinscale SHARED + src/boostAsioLinkageFix.cpp src/qutex.cpp src/componentThread.cpp src/component.cpp diff --git a/include/spinscale/co/coConditionVariable.h b/include/spinscale/co/coConditionVariable.h index 4391201..02cdfce 100644 --- a/include/spinscale/co/coConditionVariable.h +++ b/include/spinscale/co/coConditionVariable.h @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include @@ -31,7 +31,7 @@ public: { public: explicit WaitingCoroutineBase( - boost::asio::io_service &callerIoContextIn) noexcept + boost::asio::io_context &callerIoContextIn) noexcept : callerIoContext(callerIoContextIn) {} @@ -40,7 +40,7 @@ public: virtual void post() noexcept = 0; public: - boost::asio::io_service &callerIoContext; + boost::asio::io_context &callerIoContext; }; template @@ -49,7 +49,7 @@ public: { public: TypedWaitingCoroutine( - boost::asio::io_service &callerIoContextIn, + boost::asio::io_context &callerIoContextIn, std::coroutine_handle callerSchedHandleIn) noexcept : WaitingCoroutineBase(callerIoContextIn), callerSchedHandle(callerSchedHandleIn) @@ -83,8 +83,8 @@ public: template bool await_suspend(std::coroutine_handle cvCallerSchedHandle) noexcept { - boost::asio::io_service &cvCallerIoContext = - sscl::ComponentThread::getSelf()->getIoService(); + boost::asio::io_context &cvCallerIoContext = + sscl::ComponentThread::getSelf()->getIoContext(); sscl::SpinLock::Guard guard(parentCv.spinLock); if (parentCv.isSignaled) { @@ -130,8 +130,8 @@ public: template DecisionFactors awaitSuspend(std::coroutine_handle cvCallerSchedHandle) noexcept { - boost::asio::io_service &cvCallerIoContext = - sscl::ComponentThread::getSelf()->getIoService(); + boost::asio::io_context &cvCallerIoContext = + sscl::ComponentThread::getSelf()->getIoContext(); parentCv.spinLock.acquire(); if (parentCv.isSignaled) @@ -197,7 +197,7 @@ public: template void enqueueWaitingCoroutine( std::coroutine_handle handle, - boost::asio::io_service &ctx) noexcept + boost::asio::io_context &ctx) noexcept { waitingCoroutines.push_back( std::make_unique>(ctx, handle)); diff --git a/include/spinscale/co/coQutex.h b/include/spinscale/co/coQutex.h index 6784a04..e5cd20a 100644 --- a/include/spinscale/co/coQutex.h +++ b/include/spinscale/co/coQutex.h @@ -14,7 +14,7 @@ #include #endif -#include +#include #include #include @@ -56,7 +56,7 @@ public: { WaitingCoroutine( std::coroutine_handle _callerSchedHandle, - boost::asio::io_service &_callerIoContext, + boost::asio::io_context &_callerIoContext, PromiseChainLink &_waitingPromise) noexcept : callerSchedHandle(_callerSchedHandle), callerIoContext(_callerIoContext), @@ -64,7 +64,7 @@ public: {} std::coroutine_handle callerSchedHandle; - boost::asio::io_service &callerIoContext; + boost::asio::io_context &callerIoContext; PromiseChainLink &waitingPromise; }; @@ -104,7 +104,7 @@ public: } coQutex.waitingCoroutines.emplace_back( std::coroutine_handle::from_address(callerSchedHandle.address()), - sscl::ComponentThread::getSelf()->getIoService(), + sscl::ComponentThread::getSelf()->getIoContext(), *acquirerChainLink); return true; } diff --git a/include/spinscale/co/group.h b/include/spinscale/co/group.h index 634fdcc..5bac0d9 100644 --- a/include/spinscale/co/group.h +++ b/include/spinscale/co/group.h @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include @@ -486,7 +486,7 @@ struct Group * would be impossible. * * So we should be able to call resume() directly here without - * post()ing to ComponentThread::getSelf()->getIoService(). + * post()ing to ComponentThread::getSelf()->getIoContext(). * * EXPLANATION: * However, in order to ensure that we keep this adapter coro @@ -494,7 +494,7 @@ struct Group * directly calling the handle. */ boost::asio::post( - sscl::ComponentThread::getSelf()->getIoService(), + sscl::ComponentThread::getSelf()->getIoContext(), groupAwaiterSchedHandleToWake); } diff --git a/include/spinscale/co/postingPromise.h b/include/spinscale/co/postingPromise.h index 17c7993..18617fe 100644 --- a/include/spinscale/co/postingPromise.h +++ b/include/spinscale/co/postingPromise.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include @@ -124,19 +124,19 @@ struct PostingPromise : public std::suspend_always { InitialSuspendPostingInvoker( - boost::asio::io_service &targetIoServiceIn, + boost::asio::io_context &targetIoContextIn, std::coroutine_handle<> targetSchedHandleIn) noexcept - : targetIoService(targetIoServiceIn), + : targetIoContext(targetIoContextIn), targetSchedHandle(targetSchedHandleIn) {} bool await_suspend(std::coroutine_handle<> const) noexcept { - boost::asio::post(targetIoService, targetSchedHandle); + boost::asio::post(targetIoContext, targetSchedHandle); return true; } - boost::asio::io_service &targetIoService; + boost::asio::io_context &targetIoContext; std::coroutine_handle<> targetSchedHandle; }; @@ -253,8 +253,8 @@ struct PostingPromise ReturnValues returnValues; std::function callerLambda; - boost::asio::io_service &callerIoContext = - sscl::ComponentThread::getSelf()->getIoService(); + boost::asio::io_context &callerIoContext = + sscl::ComponentThread::getSelf()->getIoContext(); std::coroutine_handle<> selfSchedHandle; std::coroutine_handle callerSchedHandle; PromiseChainLink *callerChainLink = nullptr; @@ -315,7 +315,7 @@ struct TaggedPostingPromise std::cout << __func__ << ": " << std::this_thread::get_id() << " Returning InitialSuspendPostingInvoker.\n"; #endif return typename PostingPromise::InitialSuspendPostingInvoker( - ThreadTag::io_service(), + ThreadTag::io_context(), this->selfSchedHandle); } }; diff --git a/include/spinscale/componentThread.h b/include/spinscale/componentThread.h index 05ba620..cadf03c 100644 --- a/include/spinscale/componentThread.h +++ b/include/spinscale/componentThread.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include @@ -36,7 +36,8 @@ class ComponentThread { protected: ComponentThread(ThreadId _id, std::string _name) - : id(_id), name(std::move(_name)), work(io_service), keepLooping(true) + : id(_id), name(std::move(_name)), + work(boost::asio::make_work_guard(io_context)), keepLooping(true) {} public: @@ -44,7 +45,7 @@ public: void cleanup(void); - boost::asio::io_service& getIoService(void) { return io_service; } + boost::asio::io_context& getIoContext(void) { return io_context; } static const std::shared_ptr getSelf(void); static bool tlsInitialized(void); @@ -66,8 +67,9 @@ public: public: ThreadId id; std::string name; - boost::asio::io_service io_service; - boost::asio::io_service::work work; + boost::asio::io_context io_context; + boost::asio::executor_work_guard< + boost::asio::io_context::executor_type> work; std::atomic keepLooping; }; @@ -153,7 +155,7 @@ public: preJoltHookFn preJoltFn) : ComponentThread(_id, std::move(name)), pinnedCpuId(-1), - pause_work(pause_io_service), + pause_work(boost::asio::make_work_guard(pause_io_context)), entryFnArguments(*this, component, preJoltFn), thread(std::move(entryPoint), std::cref(entryFnArguments)) {} @@ -198,7 +200,7 @@ public: * coroutine state while the handler is still unwinding. */ boost::asio::post( - ComponentThread::getPptr()->getIoService(), + ComponentThread::getPptr()->getIoContext(), [handle]() { handle.resume(); }); }} { @@ -296,8 +298,9 @@ public: public: int pinnedCpuId; - boost::asio::io_service pause_io_service; - boost::asio::io_service::work pause_work; + boost::asio::io_context pause_io_context; + boost::asio::executor_work_guard< + boost::asio::io_context::executor_type> pause_work; public: EntryFnArguments entryFnArguments; diff --git a/include/spinscale/cps/asynchronousBridge.h b/include/spinscale/cps/asynchronousBridge.h index febb2c3..79808a4 100644 --- a/include/spinscale/cps/asynchronousBridge.h +++ b/include/spinscale/cps/asynchronousBridge.h @@ -3,34 +3,35 @@ #include #include -#include +#include +#include namespace sscl::cps { class AsynchronousBridge { public: - AsynchronousBridge(boost::asio::io_service &io_service) - : isAsyncOperationComplete(false), io_service(io_service) + AsynchronousBridge(boost::asio::io_context &io_context) + : isAsyncOperationComplete(false), io_context(io_context) {} void setAsyncOperationComplete(void) { /** EXPLANATION: * This empty post()ed message is necessary to ensure that the thread - * that's waiting on the io_service is signaled to wake up and check - * the io_service's queue. + * that's waiting on the io_context is signaled to wake up and check + * the io_context's queue. */ isAsyncOperationComplete.store(true); - io_service.post([]{}); + boost::asio::post(io_context, []{}); } - void waitForAsyncOperationCompleteOrIoServiceStopped(void) + void waitForAsyncOperationCompleteOrIoContextStopped(void) { for (;;) { - io_service.run_one(); - if (isAsyncOperationComplete.load() || io_service.stopped()) + io_context.run_one(); + if (isAsyncOperationComplete.load() || io_context.stopped()) { break; } /** EXPLANATION: @@ -45,12 +46,12 @@ public: } } - bool exitedBecauseIoServiceStopped(void) const - { return io_service.stopped(); } + bool exitedBecauseIoContextStopped(void) const + { return io_context.stopped(); } private: std::atomic isAsyncOperationComplete; - boost::asio::io_service &io_service; + boost::asio::io_context &io_context; }; } // namespace sscl::cps diff --git a/include/spinscale/cps/asynchronousContinuation.h b/include/spinscale/cps/asynchronousContinuation.h index c21f8fb..5830789 100644 --- a/include/spinscale/cps/asynchronousContinuation.h +++ b/include/spinscale/cps/asynchronousContinuation.h @@ -90,7 +90,7 @@ public: * LockedNonPostedAsynchronousContinuation because the only way to implement * non-posted locking would be via busy-spinning or sleeplocks. This would * eliminate the throughput advantage from our Qspinning mechanism, which - * relies on re-posting to the io_service queue when locks are unavailable. + * relies on re-posting to the io_context queue when locks are unavailable. */ template class NonPostedAsynchronousContinuation @@ -141,7 +141,7 @@ public: if (AsynchronousContinuation::originalCallback .callbackFn) { - caller->getIoService().post( + boost::asio::post(caller->getIoContext(), STC(std::bind( AsynchronousContinuation::originalCallback .callbackFn, diff --git a/include/spinscale/cps/callableTracer.h b/include/spinscale/cps/callableTracer.h index efd8b4c..0f81c96 100644 --- a/include/spinscale/cps/callableTracer.h +++ b/include/spinscale/cps/callableTracer.h @@ -15,7 +15,7 @@ namespace sscl::cps { * * This class wraps any callable object with metadata (caller function name, * line number, and return addresses) to help debug cases where callables - * posted to boost::asio::io_service have gone out of scope. The metadata + * posted to boost::asio::io_context have gone out of scope. The metadata * can be accessed from the callable's address when debugging. */ class CallableTracer @@ -100,7 +100,7 @@ private: * - Fallback: nullptr for return addresses * * Usage: - * thread->getIoService().post( + * boost::asio::post(thread->getIoContext(), * STC(std::bind(&SomeClass::method, this, arg1, arg2))); */ #ifdef CONFIG_DEBUG_TRACE_CALLABLES diff --git a/include/spinscale/cps/lockSet.h b/include/spinscale/cps/lockSet.h index e4956e3..b86b1fe 100644 --- a/include/spinscale/cps/lockSet.h +++ b/include/spinscale/cps/lockSet.h @@ -83,7 +83,7 @@ public: * time it will leave the qutexQ is when the program terminates. * * I'm not sure we'll actually cancal all in-flight async sequences -- - * and especially not all those that aren't even in any io_service queues. + * and especially not all those that aren't even in any io_context queues. * To whatever extent these objects get cleaned up, they'll probably be * cleaned up in the qutexQ's std::list destructor -- and that won't * execute any fancy cleanup logic. It'll just clear() out the list. diff --git a/include/spinscale/cps/lockerAndInvokerBase.h b/include/spinscale/cps/lockerAndInvokerBase.h index 466f4ef..0c96d6d 100644 --- a/include/spinscale/cps/lockerAndInvokerBase.h +++ b/include/spinscale/cps/lockerAndInvokerBase.h @@ -39,7 +39,7 @@ public: virtual List::iterator getLockvokerIteratorForQutex(Qutex& qutex) const = 0; /** - * @brief Awaken this lockvoker by posting it to its io_service + * @brief Awaken this lockvoker by posting it to its io_context * @param forceAwaken If true, post even if already awake */ virtual void awaken(bool forceAwaken = false) = 0; @@ -55,12 +55,12 @@ public: * * Compare by the address of the continuation objects. Why? * Because there's no guarantee that the lockvoker object that was - * passed in by the io_service invocation is the same object as that + * passed in by the io_context invocation is the same object as that * which is in the qutexQs. Especially because we make_shared() a * copy when registerInQutexQueues()ing. * * Generally when we "wake" a lockvoker by enqueuing it, boost's - * io_service::post will copy the lockvoker object. + * io_context::post will copy the lockvoker object. */ bool operator==(const LockerAndInvokerBase &other) const { diff --git a/include/spinscale/cps/serializedAsynchronousContinuation.h b/include/spinscale/cps/serializedAsynchronousContinuation.h index 3c0f783..2cf424c 100644 --- a/include/spinscale/cps/serializedAsynchronousContinuation.h +++ b/include/spinscale/cps/serializedAsynchronousContinuation.h @@ -65,7 +65,7 @@ public: * @brief LockerAndInvoker - Template class for lockvoking mechanism * * This class wraps a std::bind result and provides locking functionality. - * When locks cannot be acquired, the object re-posts itself to the io_service + * When locks cannot be acquired, the object re-posts itself to the io_context * queue, implementing the "spinqueueing" pattern. */ template @@ -74,10 +74,10 @@ public: { public: /** - * @brief Constructor that immediately posts to io_service + * @brief Constructor that immediately posts to io_context * @param serializedContinuation Reference to the serialized continuation - * containing LockSet and target io_service - * @param target The ComponentThread whose io_service to post to + * containing LockSet and target io_context + * @param target The ComponentThread whose io_context to post to * @param invocationTarget The std::bind result to invoke when locks are acquired */ LockerAndInvoker( @@ -127,7 +127,7 @@ public: } /** - * @brief Awaken this lockvoker by posting it to its io_service + * @brief Awaken this lockvoker by posting it to its io_context * @param forceAwaken If true, post even if already awake */ void awaken(bool forceAwaken = false) override @@ -138,7 +138,7 @@ public: if (prevVal == true && !forceAwaken) { return; } - target->getIoService().post(*this); + boost::asio::post(target->getIoContext(), *this); } size_t getLockSetSize() const override @@ -161,14 +161,14 @@ public: * the AsyncContinuation sh_ptr (which the Lockvoker contains within * itself) alive without wasting too much memory. * - * This way the io_service objects can remove the lockvoker from + * This way the io_context objects can remove the lockvoker from * their queues and there'll be a copy of the lockvoker in each * Qutex's queue. * * For non-serialized, posted continuations, they won't be removed - * from the io_service queue until they're executed, so there's no + * from the io_context queue until they're executed, so there's no * need to create copies of them. Lockvokers are removed from their - * io_service, potentially without being executed if they fail to + * io_context, potentially without being executed if they fail to * acquire all locks. */ void registerInLockSet() @@ -185,7 +185,7 @@ public: * * Sets isAwake=true before calling awaken with forceAwaken to ensure * that none of the locks we just registered with awaken()s a duplicate - * copy of this lockvoker on the io_service. + * copy of this lockvoker on the io_context. */ void firstWake() { @@ -213,8 +213,17 @@ public: { return isDeadlockLikely(); } #ifdef CONFIG_ENABLE_DEBUG_LOCKS - struct obsolete { - bool traceContinuationHistoryForGridlockOn(Qutex &firstFailedQutex); + friend struct obsolete; + + struct obsolete + { + explicit obsolete(LockerAndInvoker &_parent) : parent(_parent) + {} + + bool traceContinuationHistoryForGridlockOn( + Qutex &firstFailedQutex); + + LockerAndInvoker &parent; }; bool traceContinuationHistoryForDeadlockOn(Qutex &firstFailedQutex); @@ -435,7 +444,8 @@ SerializedAsynchronousContinuation * should eventually be able to acquire that lock. */ for (std::shared_ptr currContin = - this->serializedContinuation.getCallersContinuationShPtr(); + parent.serializedContinuation + .getCallersContinuationShPtr(); currContin != nullptr; currContin = currContin->getCallersContinuationShPtr()) { @@ -484,7 +494,7 @@ void SerializedAsynchronousContinuation if (!serializedContinuation.requiredLocks.tryAcquireOrBackOff( *this, firstFailedQutexRet)) { - // Just allow this lockvoker to be dropped from its io_service. + // Just allow this lockvoker to be dropped from its io_context. allowAwakening(); if (!deadlockLikely && !gridlockLikely) { return; } diff --git a/src/component.cpp b/src/component.cpp index 81939e5..99bf5c8 100644 --- a/src/component.cpp +++ b/src/component.cpp @@ -27,10 +27,10 @@ void PuppetComponent::defaultPuppetMain( if (args.preJoltHook) { args.preJoltHook(thr); } /** FIXME: - * Figure out why we don't call reset() here, and then explicitly document + * Figure out why we don't call restart() here, and then explicitly document * it. */ - thr.getIoService().run(); + thr.getIoContext().run(); thr.initializeTls(); comp.postJoltHook(); @@ -52,15 +52,15 @@ void PuppetComponent::defaultPuppetMain( /** EXPLANATION: * This reset() call is crucial for async bridging patterns * to work. - * When the outermost thread's io_service is stop()ped (e.g., + * When the outermost thread's io_context is stop()ped (e.g., * from JOLT sequence), it won't process any new work until - * reset() is called, even if nested async operations try to + * restart() is called, even if nested async operations try to * post work to it. This means async bridges invoked from * the outermost thread main sequence won't work until this - * reset() call. + * restart() call. */ - thr.getIoService().reset(); - thr.getIoService().run(); + thr.getIoContext().restart(); + thr.getIoContext().run(); } catch (const std::exception& e) { diff --git a/src/componentThread.cpp b/src/componentThread.cpp index a3ac71c..6aabfb8 100644 --- a/src/componentThread.cpp +++ b/src/componentThread.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -49,7 +49,7 @@ std::shared_ptr ComponentThread::getPptr() void PuppeteerThread::exitLoop(void) { keepLooping = false; - getIoService().stop(); + getIoContext().stop(); std::cout << name << ": Signaled main loop to exit." << "\n"; } @@ -104,7 +104,7 @@ public: "JOLT request." << "\n"; - target->io_service.stop(); + target->io_context.stop(); callOriginalCb(); } @@ -130,7 +130,7 @@ public: "exitThread (main queue)." << "\n"; target->cleanup(); - target->io_service.stop(); + target->io_context.stop(); callOriginalCb(); } @@ -142,8 +142,8 @@ public: "exitThread (pause queue)."<< "\n"; target->cleanup(); - target->pause_io_service.stop(); - target->io_service.stop(); + target->pause_io_context.stop(); + target->io_context.stop(); callOriginalCb(); } @@ -159,8 +159,8 @@ public: * have a chance to invoke the callback until it's unblocked. */ callOriginalCb(); - target->pause_io_service.reset(); - target->pause_io_service.run(); + target->pause_io_context.restart(); + target->pause_io_context.run(); } void resumeThreadReq1_posted( @@ -170,7 +170,7 @@ public: std::cout << __func__ << ": Thread '" << target->name << "': handling " "resumeThread." << "\n"; - target->pause_io_service.stop(); + target->pause_io_context.stop(); callOriginalCb(); } }; @@ -210,7 +210,7 @@ void PuppetThread::joltThreadReq( auto request = std::make_shared( puppeteer, selfPtr, callback); - this->getIoService().post( + boost::asio::post(this->getIoContext(), STC(std::bind( &ThreadLifetimeMgmtOp::joltThreadReq1_posted, request.get(), request))); @@ -224,7 +224,7 @@ void PuppetThread::startThreadReq(cps::Callback callba caller, std::static_pointer_cast(shared_from_this()), callback); - this->getIoService().post( + boost::asio::post(this->getIoContext(), STC(std::bind( &ThreadLifetimeMgmtOp::startThreadReq1_posted, request.get(), request))); @@ -237,12 +237,12 @@ void PuppetThread::exitThreadReq(cps::Callback callbac caller, std::static_pointer_cast(shared_from_this()), callback); - this->getIoService().post( + boost::asio::post(this->getIoContext(), STC(std::bind( &ThreadLifetimeMgmtOp::exitThreadReq1_mainQueue_posted, request.get(), request))); - pause_io_service.post( + boost::asio::post(pause_io_context, STC(std::bind( &ThreadLifetimeMgmtOp::exitThreadReq1_pauseQueue_posted, request.get(), request))); @@ -261,7 +261,7 @@ void PuppetThread::pauseThreadReq(cps::Callback callba caller, std::static_pointer_cast(shared_from_this()), callback); - this->getIoService().post( + boost::asio::post(this->getIoContext(), STC(std::bind( &ThreadLifetimeMgmtOp::pauseThreadReq1_posted, request.get(), request))); @@ -275,13 +275,13 @@ void PuppetThread::resumeThreadReq(cps::Callback callb + ": invoked on puppeteer thread"); } - // Post to the pause_io_service to unblock the paused thread + // Post to the pause_io_context to unblock the paused thread std::shared_ptr caller = getSelf(); auto request = std::make_shared( caller, std::static_pointer_cast(shared_from_this()), callback); - pause_io_service.post( + boost::asio::post(pause_io_context, STC(std::bind( &ThreadLifetimeMgmtOp::resumeThreadReq1_posted, request.get(), request))); diff --git a/src/puppeteerComponent.cpp b/src/puppeteerComponent.cpp index 184ba89..2e1ef4c 100644 --- a/src/puppeteerComponent.cpp +++ b/src/puppeteerComponent.cpp @@ -16,8 +16,8 @@ void PuppeteerComponent::defaultPuppeteerMain( if (args.preJoltHook) { args.preJoltHook(thr); } - thr.getIoService().reset(); - thr.getIoService().run(); + thr.getIoContext().restart(); + thr.getIoContext().run(); thr.initializeTls(); comp.postJoltHook(); @@ -40,17 +40,17 @@ void PuppeteerComponent::defaultPuppeteerMain( try { /** EXPLANATION: - * This reset() call is crucial for async bridging + * This restart() call is crucial for async bridging * patterns to work. - * When the outermost thread's io_service is stop()ped + * When the outermost thread's io_context is stop()ped * (e.g., from JOLT sequence), it won't process any new - * work until reset() is called, even if nested async + * work until restart() is called, even if nested async * operations try to post work to it. This means async * bridges invoked from the outermost thread main sequence - * won't work until this reset() call. + * won't work until this restart() call. */ - thr.getIoService().reset(); - thr.getIoService().run(); + thr.getIoContext().restart(); + thr.getIoContext().run(); } catch (const std::exception& e) { diff --git a/src/qutex.cpp b/src/qutex.cpp index ad1eba8..39eadf3 100644 --- a/src/qutex.cpp +++ b/src/qutex.cpp @@ -288,8 +288,8 @@ void Qutex::backoff( * (Assume that Lv2 was not at the front of the common qutex's * internal queue -- it only needed to be in the top 66%.) * Lv1 tries to acquire the common lock and fails. It gets taken off of - * its io_service. It's now asleep until it gets - * re-added into an io_service. + * its io_context. It's now asleep until it gets + * re-added into an io_context. * Lv2 fails to acquire the other 2 locks it needs and backoff()s from * the common lock it shares with Lv1. * @@ -357,7 +357,7 @@ void Qutex::release() * Just before Lv1 can acquire the common lock, Lv2 acquires it now, * because it only needs to be in the top 66% to succeed. * Lv1 checks the currOwner and sees that it's owned. Lv1 is now - * dequeued from its io_service. It won't be awakened until someone + * dequeued from its io_context. It won't be awakened until someone * awakens it. * Lv2 finishes its critical section and releas()es the common lock. * Lv2 was not at the front of the qutexQ, so it does NOT awaken the