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

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

Issue 2373363002: Test lock checks.
Patch Set: another test Created 4 years, 2 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
« no previous file with comments | « base/synchronization/condition_variable_win.cc ('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 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 10
11 #if DCHECK_IS_ON() 11 #if DCHECK_IS_ON()
12 12
13 namespace base { 13 namespace base {
14 14
15 Lock::Lock() : lock_() { 15 Lock::Lock() : lock_() {
16 } 16 }
17 17
18 Lock::~Lock() { 18 Lock::~Lock() {
19 DCHECK(owning_thread_ref_.is_null()); 19 DCHECK(owning_thread_ref_.is_null());
20 } 20 }
21 21
22 void Lock::AssertAcquired() const { 22 void Lock::AssertAcquired() const {
23 DCHECK(owning_thread_ref_ == PlatformThread::CurrentRef()); 23 CHECK(owning_thread_ref_ == PlatformThread::CurrentRef());
24 } 24 }
25 25
26 void Lock::CheckHeldAndUnmark() { 26 void Lock::CheckHeldAndUnmark() {
27 DCHECK(owning_thread_ref_ == PlatformThread::CurrentRef()); 27 CHECK(owning_thread_ref_ == PlatformThread::CurrentRef());
28 owning_thread_ref_ = PlatformThreadRef(); 28 owning_thread_ref_ = PlatformThreadRef();
29 } 29 }
30 30
31 void Lock::CheckUnheldAndMark() { 31 void Lock::CheckUnheldAndMark() {
32 DCHECK(owning_thread_ref_.is_null()); 32 CHECK(owning_thread_ref_.is_null());
33 owning_thread_ref_ = PlatformThread::CurrentRef(); 33 owning_thread_ref_ = PlatformThread::CurrentRef();
34 } 34 }
35 35
36 } // namespace base 36 } // namespace base
37 37
38 #endif // DCHECK_IS_ON() 38 #endif // DCHECK_IS_ON()
OLDNEW
« no previous file with comments | « base/synchronization/condition_variable_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698