From 18b4671192d10429ec59d068f098cde3a2b69b7e Mon Sep 17 00:00:00 2001 From: Grabt234 Date: Tue, 12 Nov 2024 19:14:23 +0200 Subject: [PATCH] Fix: for stop restart impl --- source/BaseModule.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/BaseModule.cpp b/source/BaseModule.cpp index b9306cf..69b9d55 100644 --- a/source/BaseModule.cpp +++ b/source/BaseModule.cpp @@ -21,6 +21,7 @@ BaseModule::~BaseModule() void BaseModule::ContinuouslyTryProcess() { + while (!m_bShutDown) { std::shared_ptr pBaseChunk; @@ -51,11 +52,24 @@ void BaseModule::StartProcessing() std::string strWarning = std::string(__FUNCTION__) + ": Processing thread already started"; PLOG_WARNING << strWarning; } + + PLOG_WARNING << GetModuleType() +" Thread joined"; + } void BaseModule::StopProcessing() { m_bShutDown = true; + + while (!m_thread.joinable()) + { + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + PLOG_INFO << "Waiting for " + GetModuleType() + " thread to shut down"; + } + + // Now we close out the thread and prepare to restart it + m_thread.join(); + m_bShutDown = false; } void BaseModule::SetNextModule(std::shared_ptr pNextModule)