Make sure the Target, Process and Thread GetGlobalProperties() static methods are thread safe.
<rdar://problem/22595283>
llvm-svn: 262053
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index f8daf08..5534ab4 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -9,6 +9,7 @@
// C Includes
// C++ Includes
+#include <mutex>
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
@@ -59,8 +60,11 @@
Thread::GetGlobalProperties()
{
static ThreadPropertiesSP g_settings_sp;
- if (!g_settings_sp)
- g_settings_sp.reset (new ThreadProperties (true));
+ static std::once_flag g_once_flag;
+ std::call_once(g_once_flag, []() {
+ if (!g_settings_sp)
+ g_settings_sp.reset (new ThreadProperties (true));
+ });
return g_settings_sp;
}