Threading: call initializeSalmanoff after io_service.reset()

This enables us to do asynchronous bridging in the functions called
by initializeSalmanoff
This commit is contained in:
2025-09-07 18:42:28 -04:00
parent 6ba6cb9cf0
commit c880f5b73e
2 changed files with 25 additions and 4 deletions
+10
View File
@@ -57,6 +57,16 @@ void ComponentThread::main(ComponentThread& self)
bool sendExceptionInd = false;
try {
/** EXPLANATION:
* This reset() call is crucial for async bridging patterns
* to work.
* When the outermost thread's io_service 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
* post work to it. This means async bridges invoked from
* the outermost thread main sequence won't work until this
* reset() call.
*/
self.getIoService().reset();
self.getIoService().run();
}
+15 -4
View File
@@ -85,10 +85,11 @@ void ComponentThread::marionetteMain(ComponentThread& self)
throw JustPrintUsageNoError(options);
}
initializeSalmanoff(mrntt::mrntt);
self.getIoService().post([]()
{
// Initialize the global Mind object
// Initialize Salmanoff first
initializeSalmanoff(mrntt::mrntt);
// Then initialize the global Mind object
globalMind->initialize();
});
@@ -105,8 +106,18 @@ void ComponentThread::marionetteMain(ComponentThread& self)
{
bool sendExceptionInd = false;
try {
self.getIoService().reset();
self.getIoService().run();
/** EXPLANATION:
* This reset() call is crucial for async bridging patterns
* to work.
* When the outermost thread's io_service 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
* post work to it. This means async bridges invoked from
* the outermost thread main sequence won't work until this
* reset() call.
*/
self.getIoService().reset();
self.getIoService().run();
}
catch (const std::exception& e)
{