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:
2025-01-11 04:34:49 -04:00
parent 876526364b
commit bffc32519b
6 changed files with 115 additions and 69 deletions
+10 -2
View File
@@ -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;
};