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:
@@ -57,6 +57,16 @@ void ComponentThread::main(ComponentThread& self)
|
|||||||
bool sendExceptionInd = false;
|
bool sendExceptionInd = false;
|
||||||
|
|
||||||
try {
|
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().reset();
|
||||||
self.getIoService().run();
|
self.getIoService().run();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,10 +85,11 @@ void ComponentThread::marionetteMain(ComponentThread& self)
|
|||||||
throw JustPrintUsageNoError(options);
|
throw JustPrintUsageNoError(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeSalmanoff(mrntt::mrntt);
|
|
||||||
self.getIoService().post([]()
|
self.getIoService().post([]()
|
||||||
{
|
{
|
||||||
// Initialize the global Mind object
|
// Initialize Salmanoff first
|
||||||
|
initializeSalmanoff(mrntt::mrntt);
|
||||||
|
// Then initialize the global Mind object
|
||||||
globalMind->initialize();
|
globalMind->initialize();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -105,8 +106,18 @@ void ComponentThread::marionetteMain(ComponentThread& self)
|
|||||||
{
|
{
|
||||||
bool sendExceptionInd = false;
|
bool sendExceptionInd = false;
|
||||||
try {
|
try {
|
||||||
self.getIoService().reset();
|
/** EXPLANATION:
|
||||||
self.getIoService().run();
|
* 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)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user