From c3ee798acc817aadc7b1bab8e51e67c3c31cfbf4 Mon Sep 17 00:00:00 2001 From: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com> Date: Thu, 12 Aug 2021 14:18:10 -0700 Subject: [PATCH] [redcode/crythread-2nd-pass] updated condition variable handling in Remote Console runtime to cut out extra unlock/lock Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com> --- Code/Tools/RemoteConsole/Core/RemoteConsoleCore.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Code/Tools/RemoteConsole/Core/RemoteConsoleCore.cpp b/Code/Tools/RemoteConsole/Core/RemoteConsoleCore.cpp index 5a137d1664..a4e7bd24fa 100644 --- a/Code/Tools/RemoteConsole/Core/RemoteConsoleCore.cpp +++ b/Code/Tools/RemoteConsole/Core/RemoteConsoleCore.cpp @@ -132,14 +132,12 @@ void SRemoteServer::StopServer() m_bAcceptClients = false; AZ::AzSock::CloseSocket(m_socket); m_socket = SOCKET_ERROR; - { - AZStd::scoped_lock lock(m_mutex); - for (TClients::iterator it = m_clients.begin(); it != m_clients.end(); ++it) - { - it->pClient->StopClient(); - } - } + AZStd::unique_lock lock(m_mutex); + for (TClients::iterator it = m_clients.begin(); it != m_clients.end(); ++it) + { + it->pClient->StopClient(); + } m_stopCondition.wait(lock, [this] { return m_clients.empty(); }); }