summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/ConstString.cpp
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2014-12-16 02:34:13 +0000
committerEnrico Granata <egranata@apple.com>2014-12-16 02:34:13 +0000
commit3cfc49f5e99dbaa015f0847c5493c4dd2ea2f944 (patch)
treefe58357c06b270292b1cff1578ff6f7871d2cab1 /lldb/source/Core/ConstString.cpp
parent986f5adf8d3e516d87a1a3793b2ec62a3d882084 (diff)
downloadbcm5719-llvm-3cfc49f5e99dbaa015f0847c5493c4dd2ea2f944.tar.gz
bcm5719-llvm-3cfc49f5e99dbaa015f0847c5493c4dd2ea2f944.zip
Instead of rolling our own, use the C++11 sanctioned solution
llvm-svn: 224310
Diffstat (limited to 'lldb/source/Core/ConstString.cpp')
-rw-r--r--lldb/source/Core/ConstString.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/lldb/source/Core/ConstString.cpp b/lldb/source/Core/ConstString.cpp
index d2d3ddb1651..56da71eaef2 100644
--- a/lldb/source/Core/ConstString.cpp
+++ b/lldb/source/Core/ConstString.cpp
@@ -11,6 +11,8 @@
#include "lldb/Host/Mutex.h"
#include "llvm/ADT/StringMap.h"
+#import <mutex>
+
using namespace lldb_private;
@@ -184,25 +186,16 @@ protected:
// we can't guarantee that some objects won't get destroyed after the
// global destructor chain is run, and trying to make sure no destructors
// touch ConstStrings is difficult. So we leak the pool instead.
-//
-// FIXME: If we are going to keep it this way we should come up with some
-// abstraction to "pthread_once" so we don't have to check the pointer
-// every time.
//----------------------------------------------------------------------
static Pool &
StringPool()
{
- static Mutex g_pool_initialization_mutex;
+ static std::once_flag g_pool_initialization_flag;
static Pool *g_string_pool = NULL;
- if (g_string_pool == NULL)
- {
- Mutex::Locker initialization_locker(g_pool_initialization_mutex);
- if (g_string_pool == NULL)
- {
- g_string_pool = new Pool();
- }
- }
+ std::call_once(g_pool_initialization_flag, [] () {
+ g_string_pool = new Pool();
+ });
return *g_string_pool;
}
OpenPOWER on IntegriCloud