diff options
author | Greg Clayton <gclayton@apple.com> | 2012-01-27 18:14:51 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-01-27 18:14:51 +0000 |
commit | e3f6b5ce48f3c6ab22b266fa43ec2d99a932c898 (patch) | |
tree | 74216c830d28a1d98b20db58b7cd2f4ca60a5943 | |
parent | b26e6bebac9c82c0e0fb92ae7e8a10ab4fb975cd (diff) | |
download | bcm5719-llvm-e3f6b5ce48f3c6ab22b266fa43ec2d99a932c898.tar.gz bcm5719-llvm-e3f6b5ce48f3c6ab22b266fa43ec2d99a932c898.zip |
Fixed a location where we would never end up unlocking our mutex in
the ClusterManager. Also switched to using Mutex::Locker where we can.
llvm-svn: 149132
-rw-r--r-- | lldb/include/lldb/Utility/SharedCluster.h | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lldb/include/lldb/Utility/SharedCluster.h b/lldb/include/lldb/Utility/SharedCluster.h index 735f0c7ae97..991af4b4fa4 100644 --- a/lldb/include/lldb/Utility/SharedCluster.h +++ b/lldb/include/lldb/Utility/SharedCluster.h @@ -55,23 +55,26 @@ public: { delete m_objects[i]; } + // Decrement refcount should have been called on this ClusterManager, + // and it should have locked the mutex, now we will unlock it before + // we destroy it... + m_mutex.Unlock(); } void ManageObject (T *new_object) { - m_mutex.Lock(); + Mutex::Locker locker (m_mutex); if (!ContainsObject(new_object)) m_objects.push_back (new_object); - m_mutex.Unlock(); } typename lldb_private::SharingPtr<T> GetSharedPointer(T *desired_object) { - m_mutex.Lock(); - m_external_ref++; - assert (ContainsObject(desired_object)); - m_mutex.Unlock(); - + { + Mutex::Locker locker (m_mutex); + m_external_ref++; + assert (ContainsObject(desired_object)); + } return typename lldb_private::SharingPtr<T> (desired_object, new imp::shared_ptr_refcount<ClusterManager> (this)); } @@ -79,10 +82,9 @@ private: bool ContainsObject (const T *desired_object) { - typename std::vector<T *>::iterator pos; - pos = std::find(m_objects.begin(), m_objects.end(), desired_object); - - return pos < m_objects.end(); + typename std::vector<T *>::iterator pos, end = m_objects.end(); + pos = std::find(m_objects.begin(), end, desired_object); + return pos != end; } void DecrementRefCount () |