summaryrefslogtreecommitdiffstats
path: root/base/synchronization
diff options
context:
space:
mode:
authorsiggi@chromium.org <siggi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 01:40:20 +0000
committersiggi@chromium.org <siggi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 01:40:20 +0000
commit34143d06a1f42ccd9df25a3856a99c882faf493e (patch)
tree6ba3033d45ffc9cdcef3d8493eebc797b37740aa /base/synchronization
parent490ebe11e8420e5471ff7bc0e7128d7404733bba (diff)
downloadchromium_src-34143d06a1f42ccd9df25a3856a99c882faf493e.zip
chromium_src-34143d06a1f42ccd9df25a3856a99c882faf493e.tar.gz
chromium_src-34143d06a1f42ccd9df25a3856a99c882faf493e.tar.bz2
Assert on deleting a held lock.
Review URL: https://chromiumcodereview.appspot.com/13728003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192980 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/synchronization')
-rw-r--r--base/synchronization/lock.cc11
-rw-r--r--base/synchronization/lock.h2
2 files changed, 10 insertions, 3 deletions
diff --git a/base/synchronization/lock.cc b/base/synchronization/lock.cc
index 6445ce8..49efbe9 100644
--- a/base/synchronization/lock.cc
+++ b/base/synchronization/lock.cc
@@ -13,9 +13,16 @@
namespace base {
+const PlatformThreadId kNoThreadId = static_cast<PlatformThreadId>(0);
+
Lock::Lock() : lock_() {
owned_by_thread_ = false;
- owning_thread_id_ = static_cast<PlatformThreadId>(0);
+ owning_thread_id_ = kNoThreadId;
+}
+
+Lock::~Lock() {
+ DCHECK(!owned_by_thread_);
+ DCHECK_EQ(kNoThreadId, owning_thread_id_);
}
void Lock::AssertAcquired() const {
@@ -27,7 +34,7 @@ void Lock::CheckHeldAndUnmark() {
DCHECK(owned_by_thread_);
DCHECK_EQ(owning_thread_id_, PlatformThread::CurrentId());
owned_by_thread_ = false;
- owning_thread_id_ = static_cast<PlatformThreadId>(0);
+ owning_thread_id_ = kNoThreadId;
}
void Lock::CheckUnheldAndMark() {
diff --git a/base/synchronization/lock.h b/base/synchronization/lock.h
index 15de446..bec37fb 100644
--- a/base/synchronization/lock.h
+++ b/base/synchronization/lock.h
@@ -32,7 +32,7 @@ class BASE_EXPORT Lock {
void AssertAcquired() const {}
#else
Lock();
- ~Lock() {}
+ ~Lock();
// NOTE: Although windows critical sections support recursive locks, we do not
// allow this, and we will commonly fire a DCHECK() if a thread attempts to