Split CompThread=>MindThr+MrnttThr; alloc globalMind in mrnttMain
We now allocate globalMind locally inside of marionetteMain. Why? Before now, we had an asymmetric threading situation where the globalMind's threads were initialized at during global constructor invocation and not on demand. This meant that we had to shut down those threads even if we had never got to the point of calling Mind::initializeReq. This significantly complicated our shutdown sequence since we had to factor in the lifetime of the std::thread objects inside of the ComponentThreads which were inside of the globalMind object. Now, if we hadn't called Mind::initializeReq, we don't have to perform any Mind::finalizeReq or adjacent operations. Shutdown is symmetrically mirrored against the operations we actually performed during execution. We introduced some complexity by splitting ComponentThreads into two derivative types (MindThread and MarionetteThread) but I think in the long term we'll be able to massage this split into a much cleaner situation overall.
This commit is contained in:
@@ -27,12 +27,12 @@ public:
|
||||
void finalizeBodyReq(mindLifetimeMgmtOpCbFn callback);
|
||||
|
||||
// ComponentThread access methods
|
||||
std::shared_ptr<ComponentThread> getComponentThread(
|
||||
std::shared_ptr<MindThread> getComponentThread(
|
||||
ComponentThread::ThreadId id) const;
|
||||
std::shared_ptr<ComponentThread> getComponentThread(
|
||||
std::shared_ptr<MindThread> getComponentThread(
|
||||
const std::string& name) const;
|
||||
// Get all this Mind's component threads.
|
||||
std::vector<std::shared_ptr<ComponentThread>> getMindThreads() const;
|
||||
std::vector<std::shared_ptr<MindThread>> getMindThreads() const;
|
||||
|
||||
// Thread management methods (moved from ComponentThread)
|
||||
typedef std::function<void()> mindThreadLifetimeMgmtOpCbFn;
|
||||
@@ -76,7 +76,7 @@ private:
|
||||
bool threadsHaveBeenJolted = false,
|
||||
bodyComponentInitialized = false;
|
||||
// Collection of ComponentThread instances (excluding marionette)
|
||||
std::vector<std::shared_ptr<ComponentThread>> componentThreads;
|
||||
std::vector<std::shared_ptr<MindThread>> componentThreads;
|
||||
|
||||
class MindLifetimeMgmtOp;
|
||||
class MindThreadLifetimeMgmtOp;
|
||||
|
||||
Reference in New Issue
Block a user