Make sure the Target, Process and Thread GetGlobalProperties() static methods are...
authorGreg Clayton <gclayton@apple.com>
Fri, 26 Feb 2016 19:38:18 +0000 (19:38 +0000)
committerGreg Clayton <gclayton@apple.com>
Fri, 26 Feb 2016 19:38:18 +0000 (19:38 +0000)
<rdar://problem/22595283>

llvm-svn: 262053

lldb/source/Target/Process.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/Thread.cpp

index 97951f49219b44dbbb88f9b25407b4f541a35c02..4f4643df89289c26c35736a4b79c975e275c0078 100644 (file)
@@ -9,6 +9,7 @@
 
 // C Includes
 // C++ Includes
+#include <mutex>
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Target/Process.h"
@@ -832,8 +833,11 @@ const ProcessPropertiesSP &
 Process::GetGlobalProperties()
 {
     static ProcessPropertiesSP g_settings_sp;
-    if (!g_settings_sp)
-        g_settings_sp.reset (new ProcessProperties (NULL));
+    static std::once_flag g_once_flag;
+    std::call_once(g_once_flag,  []() {
+        if (!g_settings_sp)
+            g_settings_sp.reset (new ProcessProperties (NULL));
+    });
     return g_settings_sp;
 }
 
index 7d3543cd52487414cc96e1336343ad4ff747990c..9719457ff41babcb329ecc4bc22c016045457b18 100644 (file)
@@ -9,6 +9,7 @@
 
 // C Includes
 // C++ Includes
+#include <mutex>
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Target/Target.h"
@@ -2778,10 +2779,11 @@ const TargetPropertiesSP &
 Target::GetGlobalProperties()
 {
     static TargetPropertiesSP g_settings_sp;
-    if (!g_settings_sp)
-    {
-        g_settings_sp.reset(new TargetProperties(nullptr));
-    }
+    static std::once_flag g_once_flag;
+    std::call_once(g_once_flag,  []() {
+        if (!g_settings_sp)
+            g_settings_sp.reset(new TargetProperties(nullptr));
+    });
     return g_settings_sp;
 }
 
index f8daf087b229112f05a4fe9c11dd709f314ed002..5534ab4f349441c07c43b9caba68de70af98cb1a 100644 (file)
@@ -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 @@ const ThreadPropertiesSP &
 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;
 }