Boost.ASIO: upgrade io_service=>io_context, finally

This commit is contained in:
2026-05-30 11:59:42 -04:00
parent f100764bd8
commit 4266af545a
26 changed files with 91 additions and 90 deletions
@@ -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<boost::asio::posix::stream_descriptor>(
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<AssembleFrameReq>(
*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)));
@@ -12,7 +12,7 @@
#include <atomic>
#include <random>
#include <liburing.h>
#include <boost/asio/io_service.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/posix/stream_descriptor.hpp>
#include <livoxProto1/device.h>
+4 -4
View File
@@ -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
@@ -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,
@@ -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)));