Boost.ASIO: upgrade io_service=>io_context, finally
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_context.hpp>
|
||||||
#include <boost/asio/deadline_timer.hpp>
|
#include <boost/asio/deadline_timer.hpp>
|
||||||
#include <boost/system/error_code.hpp>
|
#include <boost/system/error_code.hpp>
|
||||||
#include <opts.h>
|
#include <opts.h>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ BroadcastListener::BroadcastListener(
|
|||||||
listeningPort(listeningPort),
|
listeningPort(listeningPort),
|
||||||
connectPort(connectPort),
|
connectPort(connectPort),
|
||||||
deviceGoneAwayCb(nullptr),
|
deviceGoneAwayCb(nullptr),
|
||||||
socket(componentThread->getIoService()),
|
socket(componentThread->getIoContext()),
|
||||||
listeningEndpoint(boost::asio::ip::udp::v4(), listeningPort),
|
listeningEndpoint(boost::asio::ip::udp::v4(), listeningPort),
|
||||||
isListening(false)
|
isListening(false)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1098,7 +1098,7 @@ void Device::startHeartbeat()
|
|||||||
|
|
||||||
// Create heartbeat timer
|
// Create heartbeat timer
|
||||||
heartbeatTimer = std::make_unique<boost::asio::deadline_timer>(
|
heartbeatTimer = std::make_unique<boost::asio::deadline_timer>(
|
||||||
componentThread->getIoService());
|
componentThread->getIoContext());
|
||||||
|
|
||||||
heartbeatActive.store(true);
|
heartbeatActive.store(true);
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace endian {
|
|||||||
// IPv4 address validation
|
// IPv4 address validation
|
||||||
inline bool isValidIPv4(const std::string& ipAddress) {
|
inline bool isValidIPv4(const std::string& ipAddress) {
|
||||||
boost::system::error_code ec;
|
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;
|
return !ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ void UdpCommandDemuxer::setupCommandSocket()
|
|||||||
|
|
||||||
// Create boost wrapper for async operations
|
// Create boost wrapper for async operations
|
||||||
cmdEndpointFdDesc = std::make_shared<boost::asio::posix::stream_descriptor>(
|
cmdEndpointFdDesc = std::make_shared<boost::asio::posix::stream_descriptor>(
|
||||||
componentThread->getIoService(), socketGuard.getFd());
|
componentThread->getIoContext(), socketGuard.getFd());
|
||||||
|
|
||||||
// Transfer ownership, prevent auto-close
|
// Transfer ownership, prevent auto-close
|
||||||
socketGuard.commit();
|
socketGuard.commit();
|
||||||
@@ -269,7 +269,7 @@ void UdpCommandDemuxer::setupPcloudDataSocket()
|
|||||||
|
|
||||||
// Create boost wrapper for async operations
|
// Create boost wrapper for async operations
|
||||||
pcloudDataFdDesc = std::make_shared<boost::asio::posix::stream_descriptor>(
|
pcloudDataFdDesc = std::make_shared<boost::asio::posix::stream_descriptor>(
|
||||||
componentThread->getIoService(), socketGuard.getFd());
|
componentThread->getIoContext(), socketGuard.getFd());
|
||||||
|
|
||||||
// Transfer ownership, prevent auto-close
|
// Transfer ownership, prevent auto-close
|
||||||
socketGuard.commit();
|
socketGuard.commit();
|
||||||
@@ -419,16 +419,16 @@ void UdpCommandDemuxer::processIncomingData()
|
|||||||
struct UdpCommandDemuxer::PendingCommandWaitDesc
|
struct UdpCommandDemuxer::PendingCommandWaitDesc
|
||||||
{
|
{
|
||||||
CommandWaitKey key;
|
CommandWaitKey key;
|
||||||
boost::asio::io_service &resumeIoService;
|
boost::asio::io_context &resumeIoContext;
|
||||||
std::atomic<bool> settled{false};
|
std::atomic<bool> settled{false};
|
||||||
UdpCommandResponseResult result{};
|
UdpCommandResponseResult result{};
|
||||||
std::coroutine_handle<> callerSchedHandle;
|
std::coroutine_handle<> callerSchedHandle;
|
||||||
|
|
||||||
PendingCommandWaitDesc(
|
PendingCommandWaitDesc(
|
||||||
CommandWaitKey keyIn,
|
CommandWaitKey keyIn,
|
||||||
boost::asio::io_service &resumeIoServiceIn)
|
boost::asio::io_context &resumeIoContextIn)
|
||||||
: key(std::move(keyIn)),
|
: key(std::move(keyIn)),
|
||||||
resumeIoService(resumeIoServiceIn)
|
resumeIoContext(resumeIoContextIn)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -458,7 +458,7 @@ void UdpCommandDemuxer::settlePendingCommandWait(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::asio::post(wait->resumeIoService, handle);
|
boost::asio::post(wait->resumeIoContext, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<UdpCommandDemuxer::PendingCommandWaitDesc>
|
std::shared_ptr<UdpCommandDemuxer::PendingCommandWaitDesc>
|
||||||
@@ -518,7 +518,7 @@ UdpCommandDemuxer::waitForCommandResponseCReq(
|
|||||||
{
|
{
|
||||||
const CommandWaitKey key{deviceIp, cmdSet, cmdId};
|
const CommandWaitKey key{deviceIp, cmdSet, cmdId};
|
||||||
auto wait = std::make_shared<PendingCommandWaitDesc>(
|
auto wait = std::make_shared<PendingCommandWaitDesc>(
|
||||||
key, componentThread->getIoService());
|
key, componentThread->getIoContext());
|
||||||
|
|
||||||
{
|
{
|
||||||
sscl::SpinLock::Guard guard(pendingWaits.lock);
|
sscl::SpinLock::Guard guard(pendingWaits.lock);
|
||||||
@@ -577,10 +577,10 @@ UdpCommandDemuxer::waitForCommandResponseCReq(
|
|||||||
* request. If the device does not respond within the timeout period,
|
* request. If the device does not respond within the timeout period,
|
||||||
* we will consider the command to have failed.
|
* we will consider the command to have failed.
|
||||||
*/
|
*/
|
||||||
boost::asio::io_service &ioService = componentThread->getIoService();
|
boost::asio::io_context &ioContext = componentThread->getIoContext();
|
||||||
std::optional<std::shared_ptr<boost::asio::deadline_timer>> raceTimer;
|
std::optional<std::shared_ptr<boost::asio::deadline_timer>> raceTimer;
|
||||||
auto timerAwaiter = adapters::boostAsio::getDeadlineTimerAReqAwaiter(
|
auto timerAwaiter = adapters::boostAsio::getDeadlineTimerAReqAwaiter(
|
||||||
ioService,
|
ioContext,
|
||||||
boost::posix_time::milliseconds(timeoutMs),
|
boost::posix_time::milliseconds(timeoutMs),
|
||||||
raceTimer);
|
raceTimer);
|
||||||
auto responseInvoker = waitForCommandResponseCReq(cmdSet, cmdId, deviceIp);
|
auto responseInvoker = waitForCommandResponseCReq(cmdSet, cmdId, deviceIp);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include <boost/asio/deadline_timer.hpp>
|
#include <boost/asio/deadline_timer.hpp>
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_context.hpp>
|
||||||
#include <boost/asio/post.hpp>
|
#include <boost/asio/post.hpp>
|
||||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||||
#include <boost/system/error_code.hpp>
|
#include <boost/system/error_code.hpp>
|
||||||
@@ -29,14 +29,14 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
DeadlineTimerAReq(
|
DeadlineTimerAReq(
|
||||||
boost::asio::io_service &resumeIoService,
|
boost::asio::io_context &resumeIoContext,
|
||||||
const boost::posix_time::milliseconds delay,
|
const boost::posix_time::milliseconds delay,
|
||||||
std::optional<std::shared_ptr<boost::asio::deadline_timer>> &timerOut)
|
std::optional<std::shared_ptr<boost::asio::deadline_timer>> &timerOut)
|
||||||
: asyncState(std::make_shared<AsyncState>()),
|
: asyncState(std::make_shared<AsyncState>()),
|
||||||
resumeIoService(resumeIoService)
|
resumeIoContext(resumeIoContext)
|
||||||
{
|
{
|
||||||
asyncState->timer =
|
asyncState->timer =
|
||||||
std::make_shared<boost::asio::deadline_timer>(resumeIoService);
|
std::make_shared<boost::asio::deadline_timer>(resumeIoContext);
|
||||||
timerOut = asyncState->timer;
|
timerOut = asyncState->timer;
|
||||||
|
|
||||||
asyncState->timer->expires_from_now(delay);
|
asyncState->timer->expires_from_now(delay);
|
||||||
@@ -85,27 +85,27 @@ private:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::asio::post(resumeIoService, handle);
|
boost::asio::post(resumeIoContext, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<AsyncState> asyncState;
|
std::shared_ptr<AsyncState> asyncState;
|
||||||
boost::asio::io_service &resumeIoService;
|
boost::asio::io_context &resumeIoContext;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline auto getDeadlineTimerAReqAwaiter(
|
inline auto getDeadlineTimerAReqAwaiter(
|
||||||
boost::asio::io_service &ioService,
|
boost::asio::io_context &ioContext,
|
||||||
const boost::posix_time::milliseconds delay)
|
const boost::posix_time::milliseconds delay)
|
||||||
{
|
{
|
||||||
std::optional<std::shared_ptr<boost::asio::deadline_timer>> timerOut;
|
std::optional<std::shared_ptr<boost::asio::deadline_timer>> timerOut;
|
||||||
return DeadlineTimerAReq(ioService, delay, timerOut);
|
return DeadlineTimerAReq(ioContext, delay, timerOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto getDeadlineTimerAReqAwaiter(
|
inline auto getDeadlineTimerAReqAwaiter(
|
||||||
boost::asio::io_service &ioService,
|
boost::asio::io_context &ioContext,
|
||||||
const boost::posix_time::milliseconds delay,
|
const boost::posix_time::milliseconds delay,
|
||||||
std::optional<std::shared_ptr<boost::asio::deadline_timer>> &timerOut)
|
std::optional<std::shared_ptr<boost::asio::deadline_timer>> &timerOut)
|
||||||
{
|
{
|
||||||
return DeadlineTimerAReq(ioService, delay, timerOut);
|
return DeadlineTimerAReq(ioContext, delay, timerOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace adapters::boostAsio
|
} // namespace adapters::boostAsio
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_context.hpp>
|
||||||
#include <boost/asio/post.hpp>
|
#include <boost/asio/post.hpp>
|
||||||
#include <spinscale/cps/callback.h>
|
#include <spinscale/cps/callback.h>
|
||||||
|
|
||||||
@@ -30,10 +30,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
CpsCallbackAReq(
|
CpsCallbackAReq(
|
||||||
boost::asio::io_service &resumeIoService,
|
boost::asio::io_context &resumeIoContext,
|
||||||
StartFn startFn)
|
StartFn startFn)
|
||||||
: asyncState(std::make_shared<AsyncState>()),
|
: asyncState(std::make_shared<AsyncState>()),
|
||||||
resumeIoService(resumeIoService)
|
resumeIoContext(resumeIoContext)
|
||||||
{
|
{
|
||||||
startFn(sscl::cps::Callback<CallbackFn>{
|
startFn(sscl::cps::Callback<CallbackFn>{
|
||||||
nullptr,
|
nullptr,
|
||||||
@@ -80,11 +80,11 @@ private:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::asio::post(resumeIoService, handle);
|
boost::asio::post(resumeIoContext, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<AsyncState> asyncState;
|
std::shared_ptr<AsyncState> asyncState;
|
||||||
boost::asio::io_service &resumeIoService;
|
boost::asio::io_context &resumeIoContext;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace cpsBoundary
|
} // namespace cpsBoundary
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ public:
|
|||||||
* The SmoCallbacks parameter provides the library with access to
|
* The SmoCallbacks parameter provides the library with access to
|
||||||
* Salmanoff's hooks.
|
* Salmanoff's hooks.
|
||||||
* The SmoThreadingModelDesc parameter provides the library with access to
|
* 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)(
|
typedef const StimBuffApiDesc &(SMO_GET_STIM_BUFF_API_DESC_FN_TYPEDEF)(
|
||||||
const SmoCallbacks& callbacks,
|
const SmoCallbacks& callbacks,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_context.hpp>
|
||||||
#include <boost/asio/deadline_timer.hpp>
|
#include <boost/asio/deadline_timer.hpp>
|
||||||
#include <spinscale/spinLock.h>
|
#include <spinscale/spinLock.h>
|
||||||
#include <spinscale/syncCancelerForAsyncWork.h>
|
#include <spinscale/syncCancelerForAsyncWork.h>
|
||||||
@@ -39,10 +39,10 @@ public:
|
|||||||
explicit StimulusProducer(
|
explicit StimulusProducer(
|
||||||
const std::shared_ptr<device::DeviceAttachmentSpec>
|
const std::shared_ptr<device::DeviceAttachmentSpec>
|
||||||
&deviceAttachmentSpec,
|
&deviceAttachmentSpec,
|
||||||
boost::asio::io_service& ioService_)
|
boost::asio::io_context& ioContext_)
|
||||||
: deviceAttachmentSpec(deviceAttachmentSpec),
|
: deviceAttachmentSpec(deviceAttachmentSpec),
|
||||||
ioService(ioService_),
|
ioContext(ioContext_),
|
||||||
timer(ioService), nDeferrals(0)
|
timer(ioContext), nDeferrals(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual ~StimulusProducer() = default;
|
virtual ~StimulusProducer() = default;
|
||||||
@@ -107,7 +107,7 @@ public:
|
|||||||
std::vector<std::shared_ptr<StimulusBuffer>> attachedStimulusBuffers;
|
std::vector<std::shared_ptr<StimulusBuffer>> attachedStimulusBuffers;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::asio::io_service& ioService;
|
boost::asio::io_context& ioContext;
|
||||||
protected:
|
protected:
|
||||||
sscl::SyncCancelerForAsyncWork stimulusProducerCanceler;
|
sscl::SyncCancelerForAsyncWork stimulusProducerCanceler;
|
||||||
private:
|
private:
|
||||||
|
|||||||
+1
-1
Submodule libspinscale updated: 0afa3e16b8...3ea1475757
@@ -1,3 +1,4 @@
|
|||||||
|
#include <boostAsioLinkageFix.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <componentThread.h>
|
#include <componentThread.h>
|
||||||
@@ -18,13 +19,13 @@ int main(int argc, char *argv[], char *envp[])
|
|||||||
*/
|
*/
|
||||||
std::cout << "CRT:" << __func__ << ": about to JOLT Mrntt with cmdline args"
|
std::cout << "CRT:" << __func__ << ": about to JOLT Mrntt with cmdline args"
|
||||||
<< '\n';
|
<< '\n';
|
||||||
smo::mrntt::thread->getIoService().post(
|
boost::asio::post(smo::mrntt::thread->getIoContext(),
|
||||||
[argc, argv, envp]()
|
[argc, argv, envp]()
|
||||||
{
|
{
|
||||||
std::cout << "Mrntt:" << __func__ << ":JOLTED: setting cmdline args"
|
std::cout << "Mrntt:" << __func__ << ":JOLTED: setting cmdline args"
|
||||||
<< '\n';
|
<< '\n';
|
||||||
sscl::CrtCommandLineArgs::set(argc, argv, envp);
|
sscl::CrtCommandLineArgs::set(argc, argv, envp);
|
||||||
smo::mrntt::thread->getIoService().stop();
|
smo::mrntt::thread->getIoContext().stop();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -13,73 +13,73 @@
|
|||||||
namespace smo {
|
namespace smo {
|
||||||
namespace mrntt {
|
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 mrntt
|
||||||
|
|
||||||
namespace body {
|
namespace body {
|
||||||
|
|
||||||
boost::asio::io_service &BodyThreadTag::io_service()
|
boost::asio::io_context &BodyThreadTag::io_context()
|
||||||
{
|
{
|
||||||
if (!mind::globalMind) {
|
if (!mind::globalMind) {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"BodyThreadTag: globalMind not initialized");
|
"BodyThreadTag: globalMind not initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
return mind::globalMind->body.thread->getIoService();
|
return mind::globalMind->body.thread->getIoContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace body
|
} // namespace body
|
||||||
|
|
||||||
namespace director {
|
namespace director {
|
||||||
|
|
||||||
boost::asio::io_service &DirectorThreadTag::io_service()
|
boost::asio::io_context &DirectorThreadTag::io_context()
|
||||||
{
|
{
|
||||||
if (!mind::globalMind) {
|
if (!mind::globalMind) {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"DirectorThreadTag: globalMind not initialized");
|
"DirectorThreadTag: globalMind not initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
return mind::globalMind->director.thread->getIoService();
|
return mind::globalMind->director.thread->getIoContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace director
|
} // namespace director
|
||||||
|
|
||||||
namespace simulator {
|
namespace simulator {
|
||||||
|
|
||||||
boost::asio::io_service &SimulatorThreadTag::io_service()
|
boost::asio::io_context &SimulatorThreadTag::io_context()
|
||||||
{
|
{
|
||||||
if (!mind::globalMind) {
|
if (!mind::globalMind) {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"SimulatorThreadTag: globalMind not initialized");
|
"SimulatorThreadTag: globalMind not initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
return mind::globalMind->canvas.thread->getIoService();
|
return mind::globalMind->canvas.thread->getIoContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace simulator
|
} // namespace simulator
|
||||||
|
|
||||||
boost::asio::io_service &SubconsciousThreadTag::io_service()
|
boost::asio::io_context &SubconsciousThreadTag::io_context()
|
||||||
{
|
{
|
||||||
if (!mind::globalMind) {
|
if (!mind::globalMind) {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"SubconsciousThreadTag: globalMind not initialized");
|
"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) {
|
if (!mind::globalMind) {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"WorldThreadTag: globalMind not initialized");
|
"WorldThreadTag: globalMind not initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
return mind::globalMind->world.thread->getIoService();
|
return mind::globalMind->world.thread->getIoContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace smo
|
} // namespace smo
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ constexpr unsigned int reattachInFlightStaleThresholdMultiplier = 4;
|
|||||||
|
|
||||||
DeviceReattacher::DeviceReattacher(
|
DeviceReattacher::DeviceReattacher(
|
||||||
DeviceManager& parent, std::shared_ptr<sscl::ComponentThread> ioThread)
|
DeviceManager& parent, std::shared_ptr<sscl::ComponentThread> ioThread)
|
||||||
: parent(parent), ioThread(ioThread), timer(ioThread->getIoService())
|
: parent(parent), ioThread(ioThread), timer(ioThread->getIoContext())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef SMO_BODY_THREAD_H
|
#ifndef SMO_BODY_THREAD_H
|
||||||
#define SMO_BODY_THREAD_H
|
#define SMO_BODY_THREAD_H
|
||||||
|
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_context.hpp>
|
||||||
#include <spinscale/co/invokers.h>
|
#include <spinscale/co/invokers.h>
|
||||||
#include <spinscale/co/postingPromise.h>
|
#include <spinscale/co/postingPromise.h>
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ namespace body {
|
|||||||
|
|
||||||
struct BodyThreadTag
|
struct BodyThreadTag
|
||||||
{
|
{
|
||||||
static boost::asio::io_service &io_service();
|
static boost::asio::io_context &io_context();
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef SMO_DIRECTOR_THREAD_H
|
#ifndef SMO_DIRECTOR_THREAD_H
|
||||||
#define SMO_DIRECTOR_THREAD_H
|
#define SMO_DIRECTOR_THREAD_H
|
||||||
|
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_context.hpp>
|
||||||
#include <spinscale/co/invokers.h>
|
#include <spinscale/co/invokers.h>
|
||||||
#include <spinscale/co/postingPromise.h>
|
#include <spinscale/co/postingPromise.h>
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ namespace director {
|
|||||||
|
|
||||||
struct DirectorThreadTag
|
struct DirectorThreadTag
|
||||||
{
|
{
|
||||||
static boost::asio::io_service &io_service();
|
static boost::asio::io_context &io_context();
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef SMO_MARIONETTE_THREAD_H
|
#ifndef SMO_MARIONETTE_THREAD_H
|
||||||
#define SMO_MARIONETTE_THREAD_H
|
#define SMO_MARIONETTE_THREAD_H
|
||||||
|
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_context.hpp>
|
||||||
#include <spinscale/co/invokers.h>
|
#include <spinscale/co/invokers.h>
|
||||||
#include <spinscale/co/postingPromise.h>
|
#include <spinscale/co/postingPromise.h>
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ namespace mrntt {
|
|||||||
|
|
||||||
struct MrnttThreadTag
|
struct MrnttThreadTag
|
||||||
{
|
{
|
||||||
static boost::asio::io_service &io_service() noexcept;
|
static boost::asio::io_context &io_context() noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef SMO_SIMULATOR_THREAD_H
|
#ifndef SMO_SIMULATOR_THREAD_H
|
||||||
#define SMO_SIMULATOR_THREAD_H
|
#define SMO_SIMULATOR_THREAD_H
|
||||||
|
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_context.hpp>
|
||||||
#include <spinscale/co/invokers.h>
|
#include <spinscale/co/invokers.h>
|
||||||
#include <spinscale/co/postingPromise.h>
|
#include <spinscale/co/postingPromise.h>
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ namespace simulator {
|
|||||||
|
|
||||||
struct SimulatorThreadTag
|
struct SimulatorThreadTag
|
||||||
{
|
{
|
||||||
static boost::asio::io_service &io_service();
|
static boost::asio::io_context &io_context();
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef SMO_SUBCONSCIOUS_THREAD_H
|
#ifndef SMO_SUBCONSCIOUS_THREAD_H
|
||||||
#define SMO_SUBCONSCIOUS_THREAD_H
|
#define SMO_SUBCONSCIOUS_THREAD_H
|
||||||
|
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_context.hpp>
|
||||||
#include <spinscale/co/invokers.h>
|
#include <spinscale/co/invokers.h>
|
||||||
#include <spinscale/co/postingPromise.h>
|
#include <spinscale/co/postingPromise.h>
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ namespace smo {
|
|||||||
|
|
||||||
struct SubconsciousThreadTag
|
struct SubconsciousThreadTag
|
||||||
{
|
{
|
||||||
static boost::asio::io_service &io_service();
|
static boost::asio::io_context &io_context();
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef SMO_WORLD_THREAD_H
|
#ifndef SMO_WORLD_THREAD_H
|
||||||
#define SMO_WORLD_THREAD_H
|
#define SMO_WORLD_THREAD_H
|
||||||
|
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_context.hpp>
|
||||||
#include <spinscale/co/invokers.h>
|
#include <spinscale/co/invokers.h>
|
||||||
#include <spinscale/co/postingPromise.h>
|
#include <spinscale/co/postingPromise.h>
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ namespace smo {
|
|||||||
|
|
||||||
struct WorldThreadTag
|
struct WorldThreadTag
|
||||||
{
|
{
|
||||||
static boost::asio::io_service &io_service();
|
static boost::asio::io_context &io_context();
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ void MarionetteComponent::exceptionInd()
|
|||||||
auto puppeteer = sscl::ComponentThread::getPptr();
|
auto puppeteer = sscl::ComponentThread::getPptr();
|
||||||
|
|
||||||
boost::asio::post(
|
boost::asio::post(
|
||||||
puppeteer->getIoService(),
|
puppeteer->getIoContext(),
|
||||||
[]
|
[]
|
||||||
{
|
{
|
||||||
mrntt.holdFinalizeCReq(
|
mrntt.holdFinalizeCReq(
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ void MarionetteComponent::postJoltHook()
|
|||||||
|
|
||||||
// Register SIGINT (Ctrl+C) and SIGSEGV handlers
|
// Register SIGINT (Ctrl+C) and SIGSEGV handlers
|
||||||
signals = std::make_unique<boost::asio::signal_set>(
|
signals = std::make_unique<boost::asio::signal_set>(
|
||||||
th->getIoService(), SIGINT);
|
th->getIoContext(), SIGINT);
|
||||||
|
|
||||||
signals->async_wait(
|
signals->async_wait(
|
||||||
[](const boost::system::error_code& ec, int signal)
|
[](const boost::system::error_code& ec, int signal)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ IoUringAssemblyEngine::IoUringAssemblyEngine(
|
|||||||
: parent(parent_),
|
: parent(parent_),
|
||||||
frameAssemblyDesc(nullptr), ring{},
|
frameAssemblyDesc(nullptr), ring{},
|
||||||
eventfdFd(-1), eventfdDesc(nullptr), eventfd_value(0),
|
eventfdFd(-1), eventfdDesc(nullptr), eventfd_value(0),
|
||||||
stallTimer(parent_.device->componentThread->getIoService()),
|
stallTimer(parent_.device->componentThread->getIoContext()),
|
||||||
nDgramsPerStagingBufferFrame(nDgramsPerStagingBufferFrame_),
|
nDgramsPerStagingBufferFrame(nDgramsPerStagingBufferFrame_),
|
||||||
assembledSlotsTracker(nDgramsPerStagingBufferFrame_),
|
assembledSlotsTracker(nDgramsPerStagingBufferFrame_),
|
||||||
randomDevice(), randomGenerator(randomDevice())
|
randomDevice(), randomGenerator(randomDevice())
|
||||||
@@ -170,9 +170,9 @@ void IoUringAssemblyEngine::finalize()
|
|||||||
bool wasAcceptingRequests = stop();
|
bool wasAcceptingRequests = stop();
|
||||||
|
|
||||||
{
|
{
|
||||||
auto& ioService = smoHooksPtr->ComponentThread_getSelf()->getIoService();
|
auto& ioContext = smoHooksPtr->ComponentThread_getSelf()->getIoContext();
|
||||||
sscl::cps::AsynchronousBridge bridge(ioService);
|
sscl::cps::AsynchronousBridge bridge(ioContext);
|
||||||
boost::asio::deadline_timer timeoutTimer(ioService);
|
boost::asio::deadline_timer timeoutTimer(ioContext);
|
||||||
|
|
||||||
/** EXPLANATION:
|
/** EXPLANATION:
|
||||||
* We wait for IOURINGASSM_ENGN_FRAME_ASSEM_TIMEOUT_MS + 1 ms to ensure
|
* We wait for IOURINGASSM_ENGN_FRAME_ASSEM_TIMEOUT_MS + 1 ms to ensure
|
||||||
@@ -196,7 +196,7 @@ void IoUringAssemblyEngine::finalize()
|
|||||||
bridge.setAsyncOperationComplete();
|
bridge.setAsyncOperationComplete();
|
||||||
});
|
});
|
||||||
|
|
||||||
bridge.waitForAsyncOperationCompleteOrIoServiceStopped();
|
bridge.waitForAsyncOperationCompleteOrIoContextStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventfdFd >= 0)
|
if (eventfdFd >= 0)
|
||||||
@@ -265,7 +265,7 @@ void IoUringAssemblyEngine::resetAndAssembleFrame(
|
|||||||
}
|
}
|
||||||
|
|
||||||
eventfdDesc = std::make_unique<boost::asio::posix::stream_descriptor>(
|
eventfdDesc = std::make_unique<boost::asio::posix::stream_descriptor>(
|
||||||
parent.device->componentThread->getIoService(), eventfdFd);
|
parent.device->componentThread->getIoContext(), eventfdFd);
|
||||||
|
|
||||||
if (!eventfdDesc)
|
if (!eventfdDesc)
|
||||||
{
|
{
|
||||||
@@ -375,7 +375,7 @@ cleanup_eventfd:
|
|||||||
if (eventfdDesc)
|
if (eventfdDesc)
|
||||||
{
|
{
|
||||||
/** EXPLANATION:
|
/** 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
|
* get any events from the eventfd after we've called
|
||||||
* assemblyCycleComplete(). So we completely deinitialize the eventfd
|
* assemblyCycleComplete(). So we completely deinitialize the eventfd
|
||||||
* descriptor.
|
* descriptor.
|
||||||
@@ -386,7 +386,7 @@ cleanup_eventfd:
|
|||||||
* is not closed.
|
* is not closed.
|
||||||
*
|
*
|
||||||
* However, we need to close the descriptor's association with the
|
* 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.
|
* when we try to create a new descriptor with the same fd.
|
||||||
*/
|
*/
|
||||||
/** CAVEAT:
|
/** CAVEAT:
|
||||||
@@ -645,7 +645,7 @@ void IoUringAssemblyEngine::assembleFrameReq(
|
|||||||
auto request = std::make_shared<AssembleFrameReq>(
|
auto request = std::make_shared<AssembleFrameReq>(
|
||||||
*this, caller, std::move(cb));
|
*this, caller, std::move(cb));
|
||||||
|
|
||||||
parent.device->componentThread->getIoService().post(
|
boost::asio::post(parent.device->componentThread->getIoContext(),
|
||||||
STC(std::bind(
|
STC(std::bind(
|
||||||
&AssembleFrameReq::assembleFrameReq1_posted,
|
&AssembleFrameReq::assembleFrameReq1_posted,
|
||||||
request.get(), request)));
|
request.get(), request)));
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <liburing.h>
|
#include <liburing.h>
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_context.hpp>
|
||||||
#include <boost/asio/deadline_timer.hpp>
|
#include <boost/asio/deadline_timer.hpp>
|
||||||
#include <boost/asio/posix/stream_descriptor.hpp>
|
#include <boost/asio/posix/stream_descriptor.hpp>
|
||||||
#include <livoxProto1/device.h>
|
#include <livoxProto1/device.h>
|
||||||
|
|||||||
@@ -355,9 +355,9 @@ attachByCreatingProducer(
|
|||||||
/* Delay here because getOrCreate just sent HandshakeReq, so device
|
/* Delay here because getOrCreate just sent HandshakeReq, so device
|
||||||
* may not yet be ready for another command.
|
* 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(
|
const bool delayOk = co_await adapters::boostAsio::getDeadlineTimerAReqAwaiter(
|
||||||
componentThread->getIoService(),
|
componentThread->getIoContext(),
|
||||||
boost::posix_time::milliseconds(LIVOX_GEN1_DEVICE_COMMAND_DELAY_MS));
|
boost::posix_time::milliseconds(LIVOX_GEN1_DEVICE_COMMAND_DELAY_MS));
|
||||||
|
|
||||||
if (!delayOk)
|
if (!delayOk)
|
||||||
@@ -538,9 +538,9 @@ livoxGen1_detachDeviceCReq(
|
|||||||
// Add 5ms delay before destroying device
|
// Add 5ms delay before destroying device
|
||||||
|
|
||||||
// Helper method to delay and then call destroyDeviceReq
|
// 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(
|
co_await adapters::boostAsio::getDeadlineTimerAReqAwaiter(
|
||||||
requestComponentThread->getIoService(),
|
requestComponentThread->getIoContext(),
|
||||||
boost::posix_time::milliseconds(LIVOX_GEN1_DEVICE_COMMAND_DELAY_MS));
|
boost::posix_time::milliseconds(LIVOX_GEN1_DEVICE_COMMAND_DELAY_MS));
|
||||||
|
|
||||||
// No other buffers - stop and remove StimProducer
|
// No other buffers - stop and remove StimProducer
|
||||||
|
|||||||
@@ -224,9 +224,9 @@ void OpenClCollatingAndMeshingEngine::finalize()
|
|||||||
*/
|
*/
|
||||||
int delayMs = std::max(OCLCOLLMESH_ENGN_FINALIZE_DELAY_MS, 0);
|
int delayMs = std::max(OCLCOLLMESH_ENGN_FINALIZE_DELAY_MS, 0);
|
||||||
|
|
||||||
auto& ioService = smoHooksPtr->ComponentThread_getSelf()->getIoService();
|
auto& ioContext = smoHooksPtr->ComponentThread_getSelf()->getIoContext();
|
||||||
sscl::cps::AsynchronousBridge bridge(ioService);
|
sscl::cps::AsynchronousBridge bridge(ioContext);
|
||||||
boost::asio::deadline_timer timeoutTimer(ioService);
|
boost::asio::deadline_timer timeoutTimer(ioContext);
|
||||||
|
|
||||||
/** EXPLANATION:
|
/** EXPLANATION:
|
||||||
* We wait for delayMs milliseconds to ensure that any in-flight OpenCL
|
* We wait for delayMs milliseconds to ensure that any in-flight OpenCL
|
||||||
@@ -248,7 +248,7 @@ void OpenClCollatingAndMeshingEngine::finalize()
|
|||||||
bridge.setAsyncOperationComplete();
|
bridge.setAsyncOperationComplete();
|
||||||
});
|
});
|
||||||
|
|
||||||
bridge.waitForAsyncOperationCompleteOrIoServiceStopped();
|
bridge.waitForAsyncOperationCompleteOrIoContextStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release OpenCL buffers via smo hooks
|
// Release OpenCL buffers via smo hooks
|
||||||
@@ -317,10 +317,10 @@ void CL_CALLBACK OpenClCollatingAndMeshingEngine::compactKernelEventCallback(
|
|||||||
if (!engine || !engine->compactKernelCb)
|
if (!engine || !engine->compactKernelCb)
|
||||||
{ return; }
|
{ 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)
|
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));
|
std::bind(engine->compactKernelCb, event_command_exec_status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -335,10 +335,10 @@ void CL_CALLBACK OpenClCollatingAndMeshingEngine::collateKernelEventCallback(
|
|||||||
if (!engine || !engine->collateKernelCb)
|
if (!engine || !engine->collateKernelCb)
|
||||||
{ return; }
|
{ 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)
|
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));
|
std::bind(engine->collateKernelCb, event_command_exec_status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1270,7 +1270,7 @@ void OpenClCollatingAndMeshingEngine::compactCollateAndMeshFrameReq(
|
|||||||
// Start with compaction if needed, then chain to collation
|
// Start with compaction if needed, then chain to collation
|
||||||
if (needsCompaction)
|
if (needsCompaction)
|
||||||
{
|
{
|
||||||
parent.device->componentThread->getIoService().post(
|
boost::asio::post(parent.device->componentThread->getIoContext(),
|
||||||
STC(std::bind(
|
STC(std::bind(
|
||||||
&CompactCollateAndMeshFrameReq
|
&CompactCollateAndMeshFrameReq
|
||||||
::compactCollateAndMeshFrameReq1_doCompact_posted,
|
::compactCollateAndMeshFrameReq1_doCompact_posted,
|
||||||
@@ -1279,7 +1279,7 @@ void OpenClCollatingAndMeshingEngine::compactCollateAndMeshFrameReq(
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Skip compaction, go straight to collation
|
// Skip compaction, go straight to collation
|
||||||
parent.device->componentThread->getIoService().post(
|
boost::asio::post(parent.device->componentThread->getIoContext(),
|
||||||
STC(std::bind(
|
STC(std::bind(
|
||||||
&CompactCollateAndMeshFrameReq
|
&CompactCollateAndMeshFrameReq
|
||||||
::compactCollateAndMeshFrameReq3_doCollate_posted,
|
::compactCollateAndMeshFrameReq3_doCollate_posted,
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ PcloudStimulusProducer::PcloudStimulusProducer(
|
|||||||
size_t nDgramsPerStagingBufferFrame)
|
size_t nDgramsPerStagingBufferFrame)
|
||||||
: StimulusProducer(
|
: StimulusProducer(
|
||||||
deviceAttachmentSpec,
|
deviceAttachmentSpec,
|
||||||
device->componentThread->getIoService()),
|
device->componentThread->getIoContext()),
|
||||||
nDgramsPerStagingBufferFrame(nDgramsPerStagingBufferFrame),
|
nDgramsPerStagingBufferFrame(nDgramsPerStagingBufferFrame),
|
||||||
device(device),
|
device(device),
|
||||||
formatDesc(formatDesc),
|
formatDesc(formatDesc),
|
||||||
@@ -764,7 +764,7 @@ void PcloudStimulusProducer::produceFrameReq(
|
|||||||
*this, caller, std::move(callback));
|
*this, caller, std::move(callback));
|
||||||
|
|
||||||
// Post the doAssemble method to the component thread
|
// Post the doAssemble method to the component thread
|
||||||
device->componentThread->getIoService().post(
|
boost::asio::post(device->componentThread->getIoContext(),
|
||||||
STC(std::bind(
|
STC(std::bind(
|
||||||
&ProduceFrameReq::produceFrameReq1_doAssemble_posted,
|
&ProduceFrameReq::produceFrameReq1_doAssemble_posted,
|
||||||
request.get(), request)));
|
request.get(), request)));
|
||||||
|
|||||||
Reference in New Issue
Block a user