ComponentThreads: now basics are working.
Next step is to get the unified event loops working generically and then we can begin region-splitting up the data in harikoff. We'll assign all the global resource managers to Marionette and then assign the Mind components to the respective component threads.
This commit is contained in:
@@ -13,7 +13,8 @@ class ComponentThread
|
||||
{
|
||||
public:
|
||||
ComponentThread()
|
||||
: work(io_service), startupSync()
|
||||
: work(io_service), startupSync(),
|
||||
thread(ComponentThread::main, std::ref(*this))
|
||||
{}
|
||||
|
||||
boost::asio::io_service& getIoService(void) { return io_service; }
|
||||
@@ -31,10 +32,13 @@ public:
|
||||
return it->second.getIoService();
|
||||
}
|
||||
|
||||
static void main(ComponentThread &self);
|
||||
static void signalThread(std::thread::id id);
|
||||
static void validateThreadIds(void);
|
||||
|
||||
public:
|
||||
boost::asio::io_service io_service;
|
||||
boost::asio::io_service::work work;
|
||||
std::thread thread;
|
||||
struct StartupSync {
|
||||
std::mutex mutex;
|
||||
std::condition_variable cv;
|
||||
@@ -43,6 +47,10 @@ public:
|
||||
StartupSync() : ready(false) {}
|
||||
} startupSync;
|
||||
|
||||
/* Always ensure that this is last so that the thread is spawned after
|
||||
* everything else.
|
||||
*/
|
||||
std::thread thread;
|
||||
static std::unordered_map<std::thread::id, ComponentThread&> componentThreads;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user