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

Side by Side Diff: base/synchronization/lock.cc

Issue 403803004: base: Enable lock dchecks with dchecks_always_on (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix condition variable too Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« base/synchronization/lock.h ('K') | « base/synchronization/lock.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file is used for debugging assertion support. The Lock class 5 // This file is used for debugging assertion support. The Lock class
6 // is functionally a wrapper around the LockImpl class, so the only 6 // is functionally a wrapper around the LockImpl class, so the only
7 // real intelligence in the class is in the debugging logic. 7 // real intelligence in the class is in the debugging logic.
8 8
9 #if !defined(NDEBUG) 9 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
10 10
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 13
14 namespace base { 14 namespace base {
15 15
16 Lock::Lock() : lock_() { 16 Lock::Lock() : lock_() {
17 } 17 }
18 18
19 Lock::~Lock() { 19 Lock::~Lock() {
20 DCHECK(owning_thread_ref_.is_null()); 20 DCHECK(owning_thread_ref_.is_null());
21 } 21 }
22 22
23 void Lock::AssertAcquired() const { 23 void Lock::AssertAcquired() const {
24 DCHECK(owning_thread_ref_ == PlatformThread::CurrentRef()); 24 DCHECK(owning_thread_ref_ == PlatformThread::CurrentRef());
25 } 25 }
26 26
27 void Lock::CheckHeldAndUnmark() { 27 void Lock::CheckHeldAndUnmark() {
28 DCHECK(owning_thread_ref_ == PlatformThread::CurrentRef()); 28 DCHECK(owning_thread_ref_ == PlatformThread::CurrentRef());
29 owning_thread_ref_ = PlatformThreadRef(); 29 owning_thread_ref_ = PlatformThreadRef();
30 } 30 }
31 31
32 void Lock::CheckUnheldAndMark() { 32 void Lock::CheckUnheldAndMark() {
33 DCHECK(owning_thread_ref_.is_null()); 33 DCHECK(owning_thread_ref_.is_null());
34 owning_thread_ref_ = PlatformThread::CurrentRef(); 34 owning_thread_ref_ = PlatformThread::CurrentRef();
35 } 35 }
36 36
37 } // namespace base 37 } // namespace base
38 38
39 #endif // NDEBUG 39 #endif // !NDEBUG || DCHECK_ALWAYS_ON
OLDNEW
« base/synchronization/lock.h ('K') | « base/synchronization/lock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698