From a283f31d7fa2b0224980e0fdf040faf25a2baebf Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Mon, 4 Dec 2023 07:41:06 -0800 Subject: [PATCH] https://telecominfraproject.atlassian.net/browse/WIFI-13172 Signed-off-by: stephb9959 --- build | 2 +- src/framework/EventBusManager.cpp | 2 -- src/framework/EventBusManager.h | 12 ++++++++++++ src/framework/MicroService.cpp | 10 ++++------ src/framework/MicroService.h | 1 - 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/build b/build index bf0d87a..7813681 100644 --- a/build +++ b/build @@ -1 +1 @@ -4 \ No newline at end of file +5 \ No newline at end of file diff --git a/src/framework/EventBusManager.cpp b/src/framework/EventBusManager.cpp index ca28ad9..66774f1 100644 --- a/src/framework/EventBusManager.cpp +++ b/src/framework/EventBusManager.cpp @@ -9,8 +9,6 @@ namespace OpenWifi { - EventBusManager::EventBusManager(Poco::Logger &L) : Logger_(L) {} - void EventBusManager::run() { Running_ = true; Utils::SetThreadName("fmwk:EventMgr"); diff --git a/src/framework/EventBusManager.h b/src/framework/EventBusManager.h index 9a7316e..fe8a82c 100644 --- a/src/framework/EventBusManager.h +++ b/src/framework/EventBusManager.h @@ -12,6 +12,16 @@ namespace OpenWifi { class EventBusManager : public Poco::Runnable { public: + EventBusManager() : + Logger_(Poco::Logger::create( + "EventBusManager", Poco::Logger::root().getChannel(), Poco::Logger::root().getLevel())) { + } + + static auto instance() { + static auto instance_ = new EventBusManager; + return instance_; + } + explicit EventBusManager(Poco::Logger &L); void run() final; void Start(); @@ -24,4 +34,6 @@ namespace OpenWifi { Poco::Logger &Logger_; }; + inline auto EventBusManager() { return EventBusManager::instance(); } + } // namespace OpenWifi diff --git a/src/framework/MicroService.cpp b/src/framework/MicroService.cpp index 6c1aed3..fabc65b 100644 --- a/src/framework/MicroService.cpp +++ b/src/framework/MicroService.cpp @@ -48,8 +48,8 @@ namespace OpenWifi { const std::string &Payload) { std::lock_guard G(InfraMutex_); - Poco::Logger &BusLogger = Poco::Logger::create( - "BusMessageReceived", Poco::Logger::root().getChannel(), Poco::Logger::root().getLevel()); + Poco::Logger &BusLogger = EventBusManager()->Logger(); + try { Poco::JSON::Parser P; auto Object = P.parse(Payload).extract(); @@ -552,14 +552,12 @@ namespace OpenWifi { for (auto i : SubSystems_) { i->Start(); } - EventBusManager_ = std::make_unique(Poco::Logger::create( - "EventBusManager", Poco::Logger::root().getChannel(), Poco::Logger::root().getLevel())); - EventBusManager_->Start(); + EventBusManager()->Start(); } void MicroService::StopSubSystemServers() { AddActivity("Stopping"); - EventBusManager_->Stop(); + EventBusManager()->Stop(); for (auto i = SubSystems_.rbegin(); i != SubSystems_.rend(); ++i) { (*i)->Stop(); } diff --git a/src/framework/MicroService.h b/src/framework/MicroService.h index 00532b4..7290bbb 100644 --- a/src/framework/MicroService.h +++ b/src/framework/MicroService.h @@ -201,7 +201,6 @@ namespace OpenWifi { Poco::JWT::Signer Signer_; Poco::Logger &Logger_; Poco::ThreadPool TimerPool_{"timer:pool", 2, 32}; - std::unique_ptr EventBusManager_; }; inline MicroService *MicroService::instance_ = nullptr;