summaryrefslogtreecommitdiffstats
path: root/base/condition_variable_posix.cc
diff options
context:
space:
mode:
authorrdsmith@google.com <rdsmith@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-13 12:26:18 +0000
committerrdsmith@google.com <rdsmith@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-13 12:26:18 +0000
commit1dd0f46d242ac273cd7ff138b9311384c60c1464 (patch)
tree86de4b54982a98e66f318371a8f1050fa60d21c2 /base/condition_variable_posix.cc
parenteb9f3008211eb1869c2caba23d21738f2c525a54 (diff)
downloadchromium_src-1dd0f46d242ac273cd7ff138b9311384c60c1464.zip
chromium_src-1dd0f46d242ac273cd7ff138b9311384c60c1464.tar.gz
chromium_src-1dd0f46d242ac273cd7ff138b9311384c60c1464.tar.bz2
Initial implementation of new AssertAcquired() functionality for Posix.
Hoisted the windows LockImpl funcitonality up into Lock and added material to ConditionVariable to adjust those shadow variables when needed. Also got rid of os_lock() primitive in Lock class by piggybacking on friend decl needed for accessing shadow variables. BUG=44091 TEST=Try bot run on Windows, Linux, Mac. Will land during low traffic time and revert on any problems or perf degradation. Review URL: http://codereview.chromium.org/2196001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49648 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/condition_variable_posix.cc')
-rw-r--r--base/condition_variable_posix.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/base/condition_variable_posix.cc b/base/condition_variable_posix.cc
index 8c5a5c2..9d08f18 100644
--- a/base/condition_variable_posix.cc
+++ b/base/condition_variable_posix.cc
@@ -16,7 +16,7 @@ using base::Time;
using base::TimeDelta;
ConditionVariable::ConditionVariable(Lock* user_lock)
- : user_mutex_(user_lock->lock_impl()->os_lock()) {
+ : user_mutex_(user_lock->lock_.os_lock()), user_lock_(user_lock) {
int rv = pthread_cond_init(&condition_, NULL);
DCHECK(rv == 0);
}
@@ -27,8 +27,14 @@ ConditionVariable::~ConditionVariable() {
}
void ConditionVariable::Wait() {
+#if !defined(NDEBUG)
+ user_lock_->CheckHeldAndUnmark();
+#endif
int rv = pthread_cond_wait(&condition_, user_mutex_);
DCHECK(rv == 0);
+#if !defined(NDEBUG)
+ user_lock_->CheckUnheldAndMark();
+#endif
}
void ConditionVariable::TimedWait(const TimeDelta& max_time) {
@@ -46,8 +52,14 @@ void ConditionVariable::TimedWait(const TimeDelta& max_time) {
abstime.tv_nsec %= Time::kNanosecondsPerSecond;
DCHECK(abstime.tv_sec >= now.tv_sec); // Overflow paranoia
+#if !defined(NDEBUG)
+ user_lock_->CheckHeldAndUnmark();
+#endif
int rv = pthread_cond_timedwait(&condition_, user_mutex_, &abstime);
DCHECK(rv == 0 || rv == ETIMEDOUT);
+#if !defined(NDEBUG)
+ user_lock_->CheckUnheldAndMark();
+#endif
}
void ConditionVariable::Broadcast() {