summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/CommandHistory.cpp
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2016-05-18 01:59:10 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2016-05-18 01:59:10 +0000
commit16ff8604690ea63a3a82dd3b156061afb84dbcf1 (patch)
treea2d912258ecb0690f4a810ca1e438fc277160326 /lldb/source/Interpreter/CommandHistory.cpp
parenta36a61d46ac3f2ea10e78ac816bca5784bc8ba35 (diff)
downloadbcm5719-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/Interpreter/CommandHistory.cpp')
-rw-r--r--lldb/source/Interpreter/CommandHistory.cpp21
1 files changed, 9 insertions, 12 deletions
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<std::recursive_mutex> guard(m_mutex);
return m_history.size();
}
bool
CommandHistory::IsEmpty () const
{
- Mutex::Locker locker(m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_history.empty();
}
const char*
CommandHistory::FindString (const char* input_str) const
{
- Mutex::Locker locker(m_mutex);
+ std::lock_guard<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> guard(m_mutex);
stop_idx = std::min(stop_idx + 1, m_history.size());
for (size_t counter = start_idx;
counter < stop_idx;
OpenPOWER on IntegriCloud