From 16ff8604690ea63a3a82dd3b156061afb84dbcf1 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 18 May 2016 01:59:10 +0000 Subject: 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 --- lldb/source/Interpreter/CommandHistory.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'lldb/source/Interpreter/CommandHistory.cpp') diff --git a/lldb/source/Interpreter/CommandHistory.cpp b/lldb/source/Interpreter/CommandHistory.cpp index 9d3c814697b..ff87e528d36 100644 --- a/lldb/source/Interpreter/CommandHistory.cpp +++ b/lldb/source/Interpreter/CommandHistory.cpp @@ -15,10 +15,7 @@ using namespace lldb; using namespace lldb_private; - -CommandHistory::CommandHistory () : - m_mutex(Mutex::eMutexTypeRecursive), - m_history() +CommandHistory::CommandHistory() : m_mutex(), m_history() {} CommandHistory::~CommandHistory () @@ -27,21 +24,21 @@ CommandHistory::~CommandHistory () size_t CommandHistory::GetSize () const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return m_history.size(); } bool CommandHistory::IsEmpty () const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return m_history.empty(); } const char* CommandHistory::FindString (const char* input_str) const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (!input_str) return nullptr; if (input_str[0] != g_repeat_char) @@ -80,7 +77,7 @@ CommandHistory::FindString (const char* input_str) const const char* CommandHistory::GetStringAtIndex (size_t idx) const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (idx < m_history.size()) return m_history[idx].c_str(); return nullptr; @@ -95,7 +92,7 @@ CommandHistory::operator [] (size_t idx) const const char* CommandHistory::GetRecentmostString () const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (m_history.empty()) return nullptr; return m_history.back().c_str(); @@ -105,7 +102,7 @@ void CommandHistory::AppendString (const std::string& str, bool reject_if_dupe) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (reject_if_dupe) { if (!m_history.empty()) @@ -120,7 +117,7 @@ CommandHistory::AppendString (const std::string& str, void CommandHistory::Clear () { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); m_history.clear(); } @@ -129,7 +126,7 @@ CommandHistory::Dump (Stream& stream, size_t start_idx, size_t stop_idx) const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); stop_idx = std::min(stop_idx + 1, m_history.size()); for (size_t counter = start_idx; counter < stop_idx; -- cgit v1.2.3