Moving eventbus to run on main thread
This commit is contained in:
1 parent
13ad22dbb1
commit
0856548414
3 files changed
+5
-7
No files matched your search
@@ -9,13 +9,13 @@ EventBus::EventBus(Logger& logger) :
|
|||||||
_logger(logger)
|
_logger(logger)
|
||||||
{
|
{
|
||||||
_logger.debug.ln ("Starting Event Bus...");
|
_logger.debug.ln ("Starting Event Bus...");
|
||||||
_thread = thread(&EventBus::run, this);
|
//_thread = thread(&EventBus::run, this);
|
||||||
_logger.debug.ln ("Event Bus Started");
|
_logger.debug.ln ("Event Bus Started");
|
||||||
}
|
}
|
||||||
|
|
||||||
EventBus::~EventBus() {
|
EventBus::~EventBus() {
|
||||||
_logger.debug.ln ("Stopping Event Bus...");
|
_logger.debug.ln ("Stopping Event Bus...");
|
||||||
_thread.join();
|
//_thread.join();
|
||||||
// destroy all events in _events vector
|
// destroy all events in _events vector
|
||||||
for (auto event : _events) { delete event; }
|
for (auto event : _events) { delete event; }
|
||||||
_logger.debug.ln ("Event Bus stopped");
|
_logger.debug.ln ("Event Bus stopped");
|
||||||
|
|||||||
@@ -40,13 +40,11 @@ class EventBus {
|
|||||||
EventBus(Logger& logger);
|
EventBus(Logger& logger);
|
||||||
~EventBus();
|
~EventBus();
|
||||||
Event& registerEvent(const string& eventID);
|
Event& registerEvent(const string& eventID);
|
||||||
|
|
||||||
private:
|
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Logger& _logger;
|
Logger& _logger;
|
||||||
thread _thread;
|
//thread _thread;
|
||||||
vector<Event*> _events;
|
vector<Event*> _events;
|
||||||
mutex _mutex;
|
mutex _mutex;
|
||||||
};
|
};
|
||||||
|
|||||||
+2
-2
@@ -54,10 +54,10 @@ int main(int args, char **argv) {
|
|||||||
//Record testrec = ARecord();
|
//Record testrec = ARecord();
|
||||||
// End of Testcode
|
// End of Testcode
|
||||||
|
|
||||||
//resolver.run();
|
eventBus.run();
|
||||||
logger.info.ln ("PLAINS successfully started.");
|
logger.info.ln ("PLAINS successfully started.");
|
||||||
// Run something on main thread...
|
// 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();
|
//std::cin.get();
|
||||||
logger.info.ln ("Shutting down PLAINS. Good Bye!");
|
logger.info.ln ("Shutting down PLAINS. Good Bye!");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user