summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2012-05-04 23:02:50 +0000
committerJim Ingham <jingham@apple.com>2012-05-04 23:02:50 +0000
commit10ebffa48a592e2e03b2e8478b03ccdd0e8da2d5 (patch)
tree32f9eceb84a66b9b7f0387d5b89ba089d5bb4fe1 /lldb/source/Host
parente326ed33a8135dca882a76128840a28c38a1e106 (diff)
downloadbcm5719-llvm-10ebffa48a592e2e03b2e8478b03ccdd0e8da2d5.tar.gz
bcm5719-llvm-10ebffa48a592e2e03b2e8478b03ccdd0e8da2d5.zip
Don't expose the pthread_mutex_t underlying the Mutex & Mutex::Locker classes.
No one was using it and Locker(pthread_mutex_t *) immediately asserts for pthread_mutex_t's that don't come from a Mutex anyway. Rather than try to make that work, we should maintain the Mutex abstraction and not pass around the platform implementation... Make Mutex::Locker::Lock take a Mutex & or a Mutex *, and remove the constructor taking a pthread_mutex_t *. You no longer need to call Mutex::GetMutex to pass your mutex to a Locker (you can't in fact, since I made it private.) llvm-svn: 156221
Diffstat (limited to 'lldb/source/Host')
-rw-r--r--lldb/source/Host/common/Condition.cpp6
-rw-r--r--lldb/source/Host/common/Mutex.cpp23
2 files changed, 11 insertions, 18 deletions
diff --git a/lldb/source/Host/common/Condition.cpp b/lldb/source/Host/common/Condition.cpp
index 535afcb0439..daa729cadca 100644
--- a/lldb/source/Host/common/Condition.cpp
+++ b/lldb/source/Host/common/Condition.cpp
@@ -78,7 +78,7 @@ Condition::Signal ()
// The current thread re-acquires the lock on "mutex".
//----------------------------------------------------------------------
int
-Condition::Wait (pthread_mutex_t *mutex, const TimeValue *abstime, bool *timed_out)
+Condition::Wait (Mutex &mutex, const TimeValue *abstime, bool *timed_out)
{
int err = 0;
do
@@ -86,10 +86,10 @@ Condition::Wait (pthread_mutex_t *mutex, const TimeValue *abstime, bool *timed_o
if (abstime && abstime->IsValid())
{
struct timespec abstime_ts = abstime->GetAsTimeSpec();
- err = ::pthread_cond_timedwait (&m_condition, mutex, &abstime_ts);
+ err = ::pthread_cond_timedwait (&m_condition, mutex.GetMutex(), &abstime_ts);
}
else
- err = ::pthread_cond_wait (&m_condition, mutex);
+ err = ::pthread_cond_wait (&m_condition, mutex.GetMutex());
} while (err == EINTR);
if (timed_out != NULL)
diff --git a/lldb/source/Host/common/Mutex.cpp b/lldb/source/Host/common/Mutex.cpp
index 06908b2344c..d519baf45b6 100644
--- a/lldb/source/Host/common/Mutex.cpp
+++ b/lldb/source/Host/common/Mutex.cpp
@@ -108,7 +108,7 @@ Mutex::Locker::Locker () :
Mutex::Locker::Locker (Mutex& m) :
m_mutex_ptr(NULL)
{
- Lock (m.GetMutex());
+ Lock (m);
}
//----------------------------------------------------------------------
@@ -121,18 +121,7 @@ Mutex::Locker::Locker (Mutex* m) :
m_mutex_ptr(NULL)
{
if (m)
- Lock (m->GetMutex());
-}
-
-//----------------------------------------------------------------------
-// Constructor with a raw pthread mutex object pointer.
-//
-// This will create a scoped mutex locking object that locks "mutex"
-//----------------------------------------------------------------------
-Mutex::Locker::Locker (pthread_mutex_t *mutex_ptr) :
- m_mutex_ptr (NULL)
-{
- Lock (mutex_ptr);
+ Lock (m);
}
//----------------------------------------------------------------------
@@ -150,8 +139,10 @@ Mutex::Locker::~Locker ()
// mutex) and lock the new "mutex" object if it is non-NULL.
//----------------------------------------------------------------------
void
-Mutex::Locker::Lock (pthread_mutex_t *mutex_ptr)
+Mutex::Locker::Lock (Mutex &mutex)
{
+ pthread_mutex_t *mutex_ptr = mutex.GetMutex();
+
// We already have this mutex locked or both are NULL...
if (m_mutex_ptr == mutex_ptr)
return;
@@ -176,8 +167,10 @@ Mutex::Locker::Unlock ()
}
bool
-Mutex::Locker::TryLock (pthread_mutex_t *mutex_ptr)
+Mutex::Locker::TryLock (Mutex &mutex)
{
+ pthread_mutex_t *mutex_ptr = mutex.GetMutex();
+
// We already have this mutex locked!
if (m_mutex_ptr == mutex_ptr)
return m_mutex_ptr != NULL;
OpenPOWER on IntegriCloud