Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1820)

Unified Diff: base/synchronization/lock.cc

Issue 13728003: Assert on deleting a held lock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Assert on deleting a held lock. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/synchronization/lock.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/synchronization/lock.cc
diff --git a/base/synchronization/lock.cc b/base/synchronization/lock.cc
index 6445ce8a853d591bb3a8a2aca63ef0fa2f6b796b..c47441e71f3e2f2f14abb6607dbb82e96fb21963 100644
--- a/base/synchronization/lock.cc
+++ b/base/synchronization/lock.cc
@@ -13,9 +13,19 @@
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_);
+
+ // This may trip the assert on unlock in the owning thread.
willchan no longer on Chromium 2013/04/08 15:28:13 I don't understand this one. We know that it's fal
Sigurður Ásgeirsson 2013/04/08 15:32:35 Depends on whether the DCHECK is set to log fatall
+ owned_by_thread_ = false;
}
void Lock::AssertAcquired() const {
« no previous file with comments | « base/synchronization/lock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698