summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/Communication.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/Core/Communication.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/Core/Communication.cpp')
-rw-r--r--lldb/source/Core/Communication.cpp53
1 files changed, 26 insertions, 27 deletions
diff --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp
index 557fb95df69..f1dcb95e8af 100644
--- a/lldb/source/Core/Communication.cpp
+++ b/lldb/source/Core/Communication.cpp
@@ -33,31 +33,30 @@ Communication::GetStaticBroadcasterClass ()
return class_name;
}
-Communication::Communication(const char *name) :
- Broadcaster(nullptr, name),
- m_connection_sp(),
- m_read_thread_enabled(false),
- m_read_thread_did_exit(false),
- m_bytes(),
- m_bytes_mutex(Mutex::eMutexTypeRecursive),
- m_write_mutex(Mutex::eMutexTypeNormal),
- m_synchronize_mutex(Mutex::eMutexTypeNormal),
- m_callback(nullptr),
- m_callback_baton(nullptr),
- m_close_on_eof(true)
+Communication::Communication(const char *name)
+ : Broadcaster(nullptr, name),
+ m_connection_sp(),
+ m_read_thread_enabled(false),
+ m_read_thread_did_exit(false),
+ m_bytes(),
+ m_bytes_mutex(),
+ m_write_mutex(),
+ m_synchronize_mutex(),
+ m_callback(nullptr),
+ m_callback_baton(nullptr),
+ m_close_on_eof(true)
{
- lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION,
- "%p Communication::Communication (name = %s)",
- this, name);
-
- SetEventName (eBroadcastBitDisconnected, "disconnected");
- SetEventName (eBroadcastBitReadThreadGotBytes, "got bytes");
- SetEventName (eBroadcastBitReadThreadDidExit, "read thread did exit");
- SetEventName (eBroadcastBitReadThreadShouldExit, "read thread should exit");
- SetEventName (eBroadcastBitPacketAvailable, "packet available");
- SetEventName (eBroadcastBitNoMorePendingInput, "no more pending input");
-
+ lldb_private::LogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION,
+ "%p Communication::Communication (name = %s)", this, name);
+
+ SetEventName(eBroadcastBitDisconnected, "disconnected");
+ SetEventName(eBroadcastBitReadThreadGotBytes, "got bytes");
+ SetEventName(eBroadcastBitReadThreadDidExit, "read thread did exit");
+ SetEventName(eBroadcastBitReadThreadShouldExit, "read thread should exit");
+ SetEventName(eBroadcastBitPacketAvailable, "packet available");
+ SetEventName(eBroadcastBitNoMorePendingInput, "no more pending input");
+
CheckInWithManager();
}
@@ -205,7 +204,7 @@ Communication::Write (const void *src, size_t src_len, ConnectionStatus &status,
{
lldb::ConnectionSP connection_sp (m_connection_sp);
- Mutex::Locker locker(m_write_mutex);
+ std::lock_guard<std::mutex> guard(m_write_mutex);
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION,
"%p Communication::Write (src = %p, src_len = %" PRIu64 ") connection = %p",
this,
@@ -277,7 +276,7 @@ Communication::JoinReadThread (Error *error_ptr)
size_t
Communication::GetCachedBytes (void *dst, size_t dst_len)
{
- Mutex::Locker locker(m_bytes_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex);
if (!m_bytes.empty())
{
// If DST is nullptr and we have a thread, then return the number
@@ -311,7 +310,7 @@ Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broad
}
else if (bytes != nullptr && len > 0)
{
- Mutex::Locker locker(m_bytes_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex);
m_bytes.append ((const char *)bytes, len);
if (broadcast)
BroadcastEventIfUnique (eBroadcastBitReadThreadGotBytes);
@@ -425,7 +424,7 @@ void
Communication::SynchronizeWithReadThread ()
{
// Only one thread can do the synchronization dance at a time.
- Mutex::Locker locker(m_synchronize_mutex);
+ std::lock_guard<std::mutex> guard(m_synchronize_mutex);
// First start listening for the synchronization event.
ListenerSP listener_sp(Listener::MakeListener("Communication::SyncronizeWithReadThread"));
OpenPOWER on IntegriCloud