CompThreads: create execOpOnAllMindThreads common helper

This allows us to execute an op on all mind threads without having
to repeatedly write loops. We've implemented wrappers to handle
start, pause, resume, exit and JOLT sequences.
This commit is contained in:
2025-08-03 08:22:45 -04:00
parent 6f6fa77498
commit 1deb92a416
3 changed files with 192 additions and 51 deletions
+14 -15
View File
@@ -1,4 +1,4 @@
#include <iostream>
#include <mind.h>
#include <componentThread.h>
@@ -6,20 +6,19 @@ namespace smo {
void Mind::initialize()
{
/* Start the threads */
for (auto& componentThread : smo::ComponentThread::componentThreads)
{
// Post startThread() to the event loop of all threads except MRNTT.
if (componentThread->id == ComponentThread::MRNTT) { continue; }
// JOLT the thread.
componentThread->getIoService().post([componentThread]()
{ componentThread->getIoService().stop(); }
);
// Now tell it to execute its initialization sequence.
componentThread->startThreadReq();
}
/* Jolt the threads, then start them */
ComponentThread::joltAllMindThreadsReq(
[]()
{
std::cout << "Mrntt: All mind threads JOLTed." << "\n";
ComponentThread::startAllMindThreadsReq(
[]()
{
std::cout << "Mrntt: All mind threads started." << "\n";
}
);
}
);
}
void Mind::finalize(void)