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:
+14
-15
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user