From c979ab03385f19970e1a422b23a6d2d9e09d888f Mon Sep 17 00:00:00 2001 From: dmcdiar Date: Wed, 4 Aug 2021 18:26:43 -0700 Subject: [PATCH] Keep the mutex locked while processing pending notifies. Signed-off-by: dmcdiar --- .../RHI/Code/Include/Atom/RHI/ObjectCollector.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/ObjectCollector.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/ObjectCollector.h index d79a86afea..3f9fed056f 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/ObjectCollector.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/ObjectCollector.h @@ -179,7 +179,6 @@ namespace AZ { m_pendingGarbage.push_back({ AZStd::move(m_pendingObjects), m_currentIteration }); } - m_mutex.unlock(); if (m_pendingNotifies.size()) { @@ -200,25 +199,19 @@ namespace AZ } latestGarbage.m_notifies.insert(latestGarbage.m_notifies.end(), m_pendingNotifies.begin(), m_pendingNotifies.end()); - - m_mutex.lock(); - m_pendingNotifies.clear(); - m_mutex.unlock(); - } else { // garbage queue is empty, notify now - m_mutex.lock(); for (auto& notifyFunction : m_pendingNotifies) { notifyFunction(); } - - m_pendingNotifies.clear(); - m_mutex.unlock(); } + + m_pendingNotifies.clear(); } + m_mutex.unlock(); size_t objectCount = 0; size_t i = 0;