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

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: Address William's comment. 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..49efbe926517342f079959386c2103295ddda0f9 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() {
« 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