diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2016-05-18 01:59:10 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2016-05-18 01:59:10 +0000 |
commit | 16ff8604690ea63a3a82dd3b156061afb84dbcf1 (patch) | |
tree | a2d912258ecb0690f4a810ca1e438fc277160326 /lldb/source/Commands/CommandObjectTarget.cpp | |
parent | a36a61d46ac3f2ea10e78ac816bca5784bc8ba35 (diff) | |
download | bcm5719-llvm-16ff8604690ea63a3a82dd3b156061afb84dbcf1.tar.gz bcm5719-llvm-16ff8604690ea63a3a82dd3b156061afb84dbcf1.zip |
remove use of Mutex in favour of std::{,recursive_}mutex
This is a pretty straightforward first pass over removing a number of uses of
Mutex in favor of std::mutex or std::recursive_mutex. The problem is that there
are interfaces which take Mutex::Locker & to lock internal locks. This patch
cleans up most of the easy cases. The only non-trivial change is in
CommandObjectTarget.cpp where a Mutex::Locker was split into two.
llvm-svn: 269877
Diffstat (limited to 'lldb/source/Commands/CommandObjectTarget.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 1d92f317f95..1e7f1e54cc6 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -1978,7 +1978,7 @@ FindModulesByName (Target *target, if (check_global_list) { // Check the global list - Mutex::Locker locker(Module::GetAllocationModuleCollectionMutex()); + std::lock_guard<std::recursive_mutex> guard(Module::GetAllocationModuleCollectionMutex()); const size_t num_modules = Module::GetNumberAllocatedModules(); ModuleSP module_sp; for (size_t image_idx = 0; image_idx<num_modules; ++image_idx) @@ -2470,7 +2470,7 @@ protected: else { // Check the global list - Mutex::Locker locker(Module::GetAllocationModuleCollectionMutex()); + std::lock_guard<std::recursive_mutex> guard(Module::GetAllocationModuleCollectionMutex()); result.AppendWarningWithFormat("Unable to find an image that matches '%s'.\n", arg_cstr); } @@ -3291,16 +3291,20 @@ protected: } size_t num_modules = 0; - Mutex::Locker locker; // This locker will be locked on the mutex in module_list_ptr if it is non-nullptr. - // Otherwise it will lock the AllocationModuleCollectionMutex when accessing - // the global module list directly. + + // This locker will be locked on the mutex in module_list_ptr if it is non-nullptr. + // Otherwise it will lock the AllocationModuleCollectionMutex when accessing + // the global module list directly. + std::unique_lock<std::recursive_mutex> guard(Module::GetAllocationModuleCollectionMutex(), std::defer_lock); + Mutex::Locker locker; + const ModuleList *module_list_ptr = nullptr; const size_t argc = command.GetArgumentCount(); if (argc == 0) { if (use_global_module_list) { - locker.Lock (Module::GetAllocationModuleCollectionMutex()); + guard.lock(); num_modules = Module::GetNumberAllocatedModules(); } else @@ -3331,6 +3335,7 @@ protected: if (module_list_ptr != nullptr) { + assert(use_global_module_list == false && "locking violation"); locker.Lock(module_list_ptr->GetMutex()); num_modules = module_list_ptr->GetSize(); } |