From 08565484142a16af8ca2dcf0b3ff8cfa980293d1 Mon Sep 17 00:00:00 2001 From: Sven Luethi Date: Wed, 7 Apr 2021 09:37:24 +0200 Subject: [PATCH] Moving eventbus to run on main thread --- src/core/EventBus.cpp | 4 ++-- src/core/include/EventBus.hpp | 6 ++---- src/core/main.cpp | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/core/EventBus.cpp b/src/core/EventBus.cpp index d34c621..634c6be 100644 --- a/src/core/EventBus.cpp +++ b/src/core/EventBus.cpp @@ -9,13 +9,13 @@ EventBus::EventBus(Logger& logger) : _logger(logger) { _logger.debug.ln ("Starting Event Bus..."); - _thread = thread(&EventBus::run, this); + //_thread = thread(&EventBus::run, this); _logger.debug.ln ("Event Bus Started"); } EventBus::~EventBus() { _logger.debug.ln ("Stopping Event Bus..."); - _thread.join(); + //_thread.join(); // destroy all events in _events vector for (auto event : _events) { delete event; } _logger.debug.ln ("Event Bus stopped"); diff --git a/src/core/include/EventBus.hpp b/src/core/include/EventBus.hpp index 65bcef5..da3d8ea 100644 --- a/src/core/include/EventBus.hpp +++ b/src/core/include/EventBus.hpp @@ -40,13 +40,11 @@ class EventBus { EventBus(Logger& logger); ~EventBus(); Event& registerEvent(const string& eventID); + void run(); - private: - void run(); - private: Logger& _logger; - thread _thread; + //thread _thread; vector _events; mutex _mutex; }; diff --git a/src/core/main.cpp b/src/core/main.cpp index 0a7940e..77751da 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -54,10 +54,10 @@ int main(int args, char **argv) { //Record testrec = ARecord(); // End of Testcode - //resolver.run(); + eventBus.run(); logger.info.ln ("PLAINS successfully started."); // Run something on main thread... - std::this_thread::sleep_for(std::chrono::seconds(15)); + //std::this_thread::sleep_for(std::chrono::seconds(15)); //std::cin.get(); logger.info.ln ("Shutting down PLAINS. Good Bye!"); }