c457ee7aca
We moved the instance of smo::Mind to global scope. I suppose we'll only support one instance of Mind per SMO process at least for now. We now track the state of Mind threads' JOLT-waiting. This allows us to centralize the Mind thread shutdown logic. Mind::finalizeReq() now takes care of all Mind thread shutdown state logic by tracking whether Mind threads need to be JOLTed first before being told to exit.
39 lines
591 B
C++
39 lines
591 B
C++
#ifndef _MIND_H
|
|
#define _MIND_H
|
|
|
|
#include <config.h>
|
|
#include <thread>
|
|
#include <functional>
|
|
|
|
#include <director/director.h>
|
|
#include <simulator/simulator.h>
|
|
|
|
namespace smo {
|
|
|
|
class Mind
|
|
{
|
|
public:
|
|
Mind(void) : threadsHaveBeenJolted(false) {}
|
|
|
|
void initialize(void);
|
|
void execute(void);
|
|
void finalizeReq(std::function<void()> callback);
|
|
|
|
public:
|
|
std::thread directorThread;
|
|
std::thread simulatorThread;
|
|
std::thread subconsciousThread;
|
|
|
|
director::Director director;
|
|
simulator::Simulator canvas;
|
|
|
|
private:
|
|
bool threadsHaveBeenJolted;
|
|
};
|
|
|
|
extern Mind mind;
|
|
|
|
} // namespace smo
|
|
|
|
#endif
|