Add Mrntt component; init globalMind in mrntt.initializeReq
This makes the initialization sequence much cleaner and conceptually well encapsulated. We also now dynamically allocate the Mind objects. They're allocated dynamically by Mrntt inside of initializeReq. This means that we no longer have to worry about jolting and cleaning up the running threads of global mind object even when we never explicitly called Mind.initializeReq. Along with other conceptual improvements to our abstractions, this patch also gets us to a real "end of program initialization" point for the first time.
This commit is contained in:
+14
-13
@@ -8,9 +8,11 @@
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
#include <component.h>
|
||||
#include <componentThread.h>
|
||||
#include <director/director.h>
|
||||
#include <simulator/simulator.h>
|
||||
#include <componentThread.h>
|
||||
#include <body/body.h>
|
||||
|
||||
namespace smo {
|
||||
|
||||
@@ -23,8 +25,6 @@ public:
|
||||
typedef std::function<void(bool)> mindLifetimeMgmtOpCbFn;
|
||||
void initializeReq(mindLifetimeMgmtOpCbFn callback);
|
||||
void finalizeReq(mindLifetimeMgmtOpCbFn callback);
|
||||
void initializeBodyReq(mindLifetimeMgmtOpCbFn callback);
|
||||
void finalizeBodyReq(mindLifetimeMgmtOpCbFn callback);
|
||||
|
||||
// ComponentThread access methods
|
||||
std::shared_ptr<MindThread> getComponentThread(
|
||||
@@ -45,15 +45,19 @@ public:
|
||||
// CPU distribution method
|
||||
void distributeAndPinThreadsAcrossCpus();
|
||||
|
||||
public:
|
||||
std::thread directorThread;
|
||||
std::thread simulatorThread;
|
||||
std::thread subconsciousThread;
|
||||
private:
|
||||
// Collection of ComponentThread instances (excluding marionette)
|
||||
std::vector<std::shared_ptr<MindThread>> componentThreads;
|
||||
|
||||
director::Director director;
|
||||
simulator::Simulator canvas;
|
||||
public:
|
||||
director::Director director;
|
||||
simulator::Simulator canvas;
|
||||
MindComponent subconscious;
|
||||
body::Body body;
|
||||
MindComponent world;
|
||||
|
||||
private:
|
||||
friend class body::Body;
|
||||
/**
|
||||
* Indicates whether all mind threads have been JOLTed at least once.
|
||||
*
|
||||
@@ -75,13 +79,10 @@ private:
|
||||
*/
|
||||
bool threadsHaveBeenJolted = false,
|
||||
bodyComponentInitialized = false;
|
||||
// Collection of ComponentThread instances (excluding marionette)
|
||||
std::vector<std::shared_ptr<MindThread>> componentThreads;
|
||||
|
||||
private:
|
||||
class MindLifetimeMgmtOp;
|
||||
class MindThreadLifetimeMgmtOp;
|
||||
class InitializeBodyReq;
|
||||
class FinalizeBodyReq;
|
||||
};
|
||||
|
||||
// Global Mind instance will be defined in marionette.cpp
|
||||
|
||||
Reference in New Issue
Block a user