mirror of
https://github.com/latentPrion/libspinscale.git
synced 2026-06-24 03:48:34 +00:00
Boost.ASIO: update io_service=>io_context
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
|
||||
#include <spinscale/componentThread.h>
|
||||
@@ -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 <typename Promise>
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
{
|
||||
public:
|
||||
TypedWaitingCoroutine(
|
||||
boost::asio::io_service &callerIoContextIn,
|
||||
boost::asio::io_context &callerIoContextIn,
|
||||
std::coroutine_handle<Promise> callerSchedHandleIn) noexcept
|
||||
: WaitingCoroutineBase(callerIoContextIn),
|
||||
callerSchedHandle(callerSchedHandleIn)
|
||||
@@ -83,8 +83,8 @@ public:
|
||||
template <typename Promise>
|
||||
bool await_suspend(std::coroutine_handle<Promise> 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 <typename Promise>
|
||||
DecisionFactors awaitSuspend(std::coroutine_handle<Promise> 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 <typename Promise>
|
||||
void enqueueWaitingCoroutine(
|
||||
std::coroutine_handle<Promise> handle,
|
||||
boost::asio::io_service &ctx) noexcept
|
||||
boost::asio::io_context &ctx) noexcept
|
||||
{
|
||||
waitingCoroutines.push_back(
|
||||
std::make_unique<TypedWaitingCoroutine<Promise>>(ctx, handle));
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <thread>
|
||||
#endif
|
||||
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
|
||||
#include <spinscale/componentThread.h>
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
{
|
||||
WaitingCoroutine(
|
||||
std::coroutine_handle<void> _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<void> 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<void>::from_address(callerSchedHandle.address()),
|
||||
sscl::ComponentThread::getSelf()->getIoService(),
|
||||
sscl::ComponentThread::getSelf()->getIoContext(),
|
||||
*acquirerChainLink);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
|
||||
#include <spinscale/componentThread.h>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
|
||||
#include <spinscale/componentThread.h>
|
||||
@@ -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<T> returnValues;
|
||||
std::function<void()> 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<void> 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<T>::InitialSuspendPostingInvoker(
|
||||
ThreadTag::io_service(),
|
||||
ThreadTag::io_context(),
|
||||
this->selfSchedHandle);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user