diff options
| -rw-r--r-- | zenstore/gc.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/zenstore/gc.cpp b/zenstore/gc.cpp index 0f7a11789..3b090cae9 100644 --- a/zenstore/gc.cpp +++ b/zenstore/gc.cpp @@ -401,11 +401,16 @@ GcScheduler::Shutdown() { if (static_cast<uint32_t>(GcSchedulerStatus::kStopped) != m_Status) { - m_Status = static_cast<uint32_t>(GcSchedulerStatus::kStopped); + bool GcIsRunning = m_Status == static_cast<uint32_t>(GcSchedulerStatus::kRunning); + m_Status = static_cast<uint32_t>(GcSchedulerStatus::kStopped); m_GcSignal.notify_one(); if (m_GcThread.joinable()) { + if (GcIsRunning) + { + ZEN_INFO("Waiting for garbage collection to complete"); + } m_GcThread.join(); } } @@ -537,7 +542,11 @@ GcScheduler::SchedulerThread() ZEN_INFO("garbage collection DONE after {}", NiceTimeSpanMs(Timer.GetElapsedTimeMs())); uint32_t RunningState = static_cast<uint32_t>(GcSchedulerStatus::kRunning); - m_Status.compare_exchange_strong(RunningState, static_cast<uint32_t>(GcSchedulerStatus::kIdle)); + if (!m_Status.compare_exchange_strong(RunningState, static_cast<uint32_t>(GcSchedulerStatus::kIdle))) + { + ZEN_ASSERT(m_Status == static_cast<uint32_t>(GcSchedulerStatus::kStopped)); + break; + } } } |