diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2019-08-19 19:49:57 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2019-08-19 19:49:57 +0000 |
commit | 928071ae4ef5e2e6342afb126518a79fde81cf8b (patch) | |
tree | 3553e54db7f1bc27ba0585fe6cef1efbd8a7b9c4 /llvm/lib/Support/ManagedStatic.cpp | |
parent | 056f1b5cc7c2133f0cb3e30e7f24808d321096d7 (diff) | |
download | llvm-928071ae4ef5e2e6342afb126518a79fde81cf8b.zip llvm-928071ae4ef5e2e6342afb126518a79fde81cf8b.tar.gz llvm-928071ae4ef5e2e6342afb126518a79fde81cf8b.tar.bz2 |
[Support] Replace sys::Mutex with their standard equivalents.
Only use a recursive mutex if it can be locked recursively.
llvm-svn: 369295
Diffstat (limited to 'llvm/lib/Support/ManagedStatic.cpp')
-rw-r--r-- | llvm/lib/Support/ManagedStatic.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/Support/ManagedStatic.cpp b/llvm/lib/Support/ManagedStatic.cpp index c51ef96..053493f 100644 --- a/llvm/lib/Support/ManagedStatic.cpp +++ b/llvm/lib/Support/ManagedStatic.cpp @@ -12,21 +12,20 @@ #include "llvm/Support/ManagedStatic.h" #include "llvm/Config/config.h" -#include "llvm/Support/Mutex.h" #include "llvm/Support/Threading.h" #include <cassert> #include <mutex> using namespace llvm; static const ManagedStaticBase *StaticList = nullptr; -static sys::Mutex *ManagedStaticMutex = nullptr; +static std::recursive_mutex *ManagedStaticMutex = nullptr; static llvm::once_flag mutex_init_flag; static void initializeMutex() { - ManagedStaticMutex = new sys::Mutex(); + ManagedStaticMutex = new std::recursive_mutex(); } -static sys::Mutex* getManagedStaticMutex() { +static std::recursive_mutex *getManagedStaticMutex() { llvm::call_once(mutex_init_flag, initializeMutex); return ManagedStaticMutex; } @@ -35,7 +34,7 @@ void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(), void (*Deleter)(void*)) const { assert(Creator); if (llvm_is_multithreaded()) { - std::lock_guard<sys::Mutex> Lock(*getManagedStaticMutex()); + std::lock_guard<std::recursive_mutex> Lock(*getManagedStaticMutex()); if (!Ptr.load(std::memory_order_relaxed)) { void *Tmp = Creator(); @@ -77,7 +76,7 @@ void ManagedStaticBase::destroy() const { /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables. void llvm::llvm_shutdown() { - std::lock_guard<sys::Mutex> Lock(*getManagedStaticMutex()); + std::lock_guard<std::recursive_mutex> Lock(*getManagedStaticMutex()); while (StaticList) StaticList->destroy(); |