Forráskód Böngészése

[redcode/crythread-2nd-pass] replaced instances of AZStd::lock_guard<> with AZStd::scoped_lock as per feedback

Signed-off-by: AMZN-ScottR <[email protected]>
AMZN-ScottR 4 éve
szülő
commit
cc3d2e9969

+ 1 - 2
Code/Editor/CryEdit.cpp

@@ -938,10 +938,9 @@ void CCryEditApp::ShowSplashScreen(CCryEditApp* app)
 
     QObject::connect(splashScreen, &QObject::destroyed, splashScreen, [=]
     {
-        g_splashScreenStateLock.lock();
+        AZStd::scoped_lock lock(g_splashScreenStateLock);
         g_pInitializeUIInfo = nullptr;
         g_splashScreen = nullptr;
-        g_splashScreenStateLock.unlock();
     });
 }
 

+ 1 - 1
Code/Editor/GameExporter.cpp

@@ -136,7 +136,7 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
             m_settings.SetHiQuality();
         }
 
-        AZStd::lock_guard<AZStd::recursive_mutex> autoLock(CGameEngine::GetPakModifyMutex());
+        AZStd::scoped_lock autoLock(CGameEngine::GetPakModifyMutex());
 
         // Close this pak file.
         if (!CloseLevelPack(m_levelPak, true))

+ 3 - 3
Code/Editor/IEditorImpl.cpp

@@ -252,7 +252,7 @@ void CEditorImpl::Uninitialize()
 
 void CEditorImpl::UnloadPlugins()
 {
-    AZStd::lock_guard<AZStd::mutex> lock(m_pluginMutex);
+    AZStd::scoped_lock lock(m_pluginMutex);
 
     // Flush core buses. We're about to unload DLLs and need to ensure we don't have module-owned functions left behind.
     AZ::Data::AssetBus::ExecuteQueuedEvents();
@@ -273,7 +273,7 @@ void CEditorImpl::UnloadPlugins()
 
 void CEditorImpl::LoadPlugins()
 {
-    AZStd::lock_guard<AZStd::mutex> lock(m_pluginMutex);
+    AZStd::scoped_lock lock(m_pluginMutex);
 
     static const QString editor_plugins_folder("EditorPlugins");
 
@@ -1460,7 +1460,7 @@ void CEditorImpl::UnregisterNotifyListener(IEditorNotifyListener* listener)
 
 ISourceControl* CEditorImpl::GetSourceControl()
 {
-    AZStd::lock_guard<AZStd::mutex> lock(m_pluginMutex);
+    AZStd::scoped_lock lock(m_pluginMutex);
 
     if (m_pSourceControl)
     {

+ 1 - 1
Code/Editor/Plugins/PerforcePlugin/PerforceSourceControl.cpp

@@ -56,7 +56,7 @@ void CPerforceSourceControl::ShowSettings()
 
 void CPerforceSourceControl::SetSourceControlState(SourceControlState state)
 {
-    AZStd::lock_guard<AZStd::mutex> lock(g_cPerforceValues);
+    AZStd::scoped_lock lock(g_cPerforceValues);
 
     switch (state)
     {

+ 1 - 1
Code/Legacy/CryCommon/CryAssert_Linux.h

@@ -80,7 +80,7 @@ bool CryAssert(const char* szCondition, const char* szFile, unsigned int line, b
 
     if (!gEnv->bNoAssertDialog && !gEnv->bIgnoreAllAsserts)
     {
-        AZStd::lock_guard<AZStd::recursive_mutex> lk (lock);
+        AZStd::scoped_lock lk(lock);
         snprintf(gs_command_str, max_len, "xterm -geometry 100x20 -n 'Assert Dialog [Linux Launcher]' -T 'Assert Dialog [Linux Launcher]' -e 'BinLinux/assert_term \"%s\" \"%s\" %d \"%s\"; echo \"$?\" > .assert_return'",
             szCondition, (file_len > 60) ? szFile + (file_len - 61) : szFile, line, gs_szMessage);
         int ret = system(gs_command_str);

+ 3 - 3
Code/Legacy/CrySystem/DebugCallStack.cpp

@@ -154,13 +154,13 @@ void DebugCallStack::SetUserDialogEnable(const bool bUserDialogEnable)
 DWORD g_idDebugThreads[10];
 const char* g_nameDebugThreads[10];
 int g_nDebugThreads = 0;
-AZStd::spin_mutex g_lockThreadDumpList = 0;
+AZStd::spin_mutex g_lockThreadDumpList;
 
 void MarkThisThreadForDebugging(const char* name)
 {
     EBUS_EVENT(AZ::Debug::EventTraceDrillerSetupBus, SetThreadName, AZStd::this_thread::get_id(), name);
 
-    AZStd::lock_guard<AZStd::spin_mutex> lock(g_lockThreadDumpList);
+    AZStd::scoped_lock lock(g_lockThreadDumpList);
     DWORD id = GetCurrentThreadId();
     if (g_nDebugThreads == sizeof(g_idDebugThreads) / sizeof(g_idDebugThreads[0]))
     {
@@ -180,7 +180,7 @@ void MarkThisThreadForDebugging(const char* name)
 
 void UnmarkThisThreadFromDebugging()
 {
-    AZStd::lock_guard<AZStd::spin_mutex> lock(g_lockThreadDumpList);
+    AZStd::scoped_lock lock(g_lockThreadDumpList);
     DWORD id = GetCurrentThreadId();
     for (int i = g_nDebugThreads - 1; i >= 0; i--)
     {

+ 4 - 4
Code/Legacy/CrySystem/Log.cpp

@@ -810,13 +810,13 @@ void CLog::PushAssetScopeName(const char* sAssetType, const char* sName)
     SAssetScopeInfo as;
     as.sType = sAssetType;
     as.sName = sName;
-    AZStd::lock_guard<AZStd::mutex> scope_lock(m_assetScopeQueueLock);
+    AZStd::scoped_lock scope_lock(m_assetScopeQueueLock);
     m_assetScopeQueue.push_back(as);
 }
 
 void CLog::PopAssetScopeName()
 {
-    AZStd::lock_guard<AZStd::mutex> scope_lock(m_assetScopeQueueLock);
+    AZStd::scoped_lock scope_lock(m_assetScopeQueueLock);
     assert(!m_assetScopeQueue.empty());
     if (!m_assetScopeQueue.empty())
     {
@@ -827,7 +827,7 @@ void CLog::PopAssetScopeName()
 //////////////////////////////////////////////////////////////////////////
 const char* CLog::GetAssetScopeString()
 {
-    AZStd::lock_guard<AZStd::mutex> scope_lock(m_assetScopeQueueLock);
+    AZStd::scoped_lock scope_lock(m_assetScopeQueueLock);
 
     m_assetScopeString.clear();
     for (size_t i = 0; i < m_assetScopeQueue.size(); i++)
@@ -1450,7 +1450,7 @@ void CLog::Update()
     {
         if (!m_threadSafeMsgQueue.empty())
         {
-            AZStd::lock_guard<AZStd::recursive_mutex> lock(m_threadSafeMsgQueue.get_lock());   // Get the lock and hold onto it until we clear the entire queue (prevents other threads adding more things in while we clear it)
+            AZStd::scoped_lock lock(m_threadSafeMsgQueue.get_lock());   // Get the lock and hold onto it until we clear the entire queue (prevents other threads adding more things in while we clear it)
             // Must be called from main thread
             SLogMsg msg;
             while (m_threadSafeMsgQueue.try_pop(msg))

+ 9 - 8
Code/Tools/RemoteConsole/Core/RemoteConsoleCore.cpp

@@ -133,19 +133,20 @@ void SRemoteServer::StopServer()
     AZ::AzSock::CloseSocket(m_socket);
     m_socket = SOCKET_ERROR;
     {
-        AZStd::lock_guard<AZStd::recursive_mutex> lock(m_mutex);
+        AZStd::scoped_lock lock(m_mutex);
         for (TClients::iterator it = m_clients.begin(); it != m_clients.end(); ++it)
         {
             it->pClient->StopClient();
         }
     }
     AZStd::unique_lock<AZStd::recursive_mutex> lock(m_mutex);
-    m_stopCondition.wait(lock, [this] { return m_clients.empty(); });}
+    m_stopCondition.wait(lock, [this] { return m_clients.empty(); });
+}
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 void SRemoteServer::ClientDone(SRemoteClient* pClient)
 {
-    AZStd::lock_guard<AZStd::recursive_mutex> lock(m_mutex);
+    AZStd::scoped_lock lock(m_mutex);
     for (TClients::iterator it = m_clients.begin(); it != m_clients.end(); ++it)
     {
         if (it->pClient == pClient)
@@ -253,7 +254,7 @@ void SRemoteServer::Run()
             continue;
         }
 
-        AZStd::lock_guard<AZStd::recursive_mutex> lock(m_mutex);
+        AZStd::scoped_lock lock(m_mutex);
         SRemoteClient* pClient = new SRemoteClient(this);
         m_clients.push_back(SRemoteClientInfo(pClient));
         pClient->StartClient(sClient);
@@ -266,7 +267,7 @@ void SRemoteServer::Run()
 /////////////////////////////////////////////////////////////////////////////////////////////
 void SRemoteServer::AddEvent(IRemoteEvent* pEvent)
 {
-    AZStd::lock_guard<AZStd::recursive_mutex> lock(m_mutex);
+    AZStd::scoped_lock lock(m_mutex);
     for (TClients::iterator it = m_clients.begin(); it != m_clients.end(); ++it)
     {
         it->pEvents->push_back(pEvent->Clone());
@@ -277,7 +278,7 @@ void SRemoteServer::AddEvent(IRemoteEvent* pEvent)
 /////////////////////////////////////////////////////////////////////////////////////////////
 void SRemoteServer::GetEvents(TEventBuffer& buffer)
 {
-    AZStd::lock_guard<AZStd::recursive_mutex> lock(m_mutex);
+    AZStd::scoped_lock lock(m_mutex);
     buffer = m_eventBuffer;
     m_eventBuffer.clear();
 }
@@ -287,7 +288,7 @@ bool SRemoteServer::WriteBuffer(SRemoteClient* pClient,  char* buffer, int& size
 {
     IRemoteEvent* pEvent = nullptr;
     {
-        AZStd::lock_guard<AZStd::recursive_mutex> lock(m_mutex);
+        AZStd::scoped_lock lock(m_mutex);
         for (TClients::iterator it = m_clients.begin(); it != m_clients.end(); ++it)
         {
             if (it->pClient == pClient)
@@ -330,7 +331,7 @@ bool SRemoteServer::ReadBuffer(const char* buffer, int data)
         {
             if (event->GetType() != eCET_Noop)
             {
-                AZStd::lock_guard<AZStd::recursive_mutex> lock(m_mutex);
+                AZStd::scoped_lock lock(m_mutex);
                 m_eventBuffer.push_back(event);
             }
             else