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

Side by Side Diff: base/lock.cc

Issue 6001010: Move platform_thread to base/threading and put in the base namespace. I left ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 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
« no previous file with comments | « base/lock.h ('k') | base/lock_unittest.cc » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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)
10 10
11 #include "base/lock.h" 11 #include "base/lock.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 13
14 using base::PlatformThread;
15 using base::PlatformThreadId;
16
14 Lock::Lock() : lock_() { 17 Lock::Lock() : lock_() {
15 owned_by_thread_ = false; 18 owned_by_thread_ = false;
16 owning_thread_id_ = static_cast<PlatformThreadId>(0); 19 owning_thread_id_ = static_cast<PlatformThreadId>(0);
17 } 20 }
18 21
19 void Lock::AssertAcquired() const { 22 void Lock::AssertAcquired() const {
20 DCHECK(owned_by_thread_); 23 DCHECK(owned_by_thread_);
21 DCHECK_EQ(owning_thread_id_, PlatformThread::CurrentId()); 24 DCHECK_EQ(owning_thread_id_, PlatformThread::CurrentId());
22 } 25 }
23 26
24 void Lock::CheckHeldAndUnmark() { 27 void Lock::CheckHeldAndUnmark() {
25 DCHECK(owned_by_thread_); 28 DCHECK(owned_by_thread_);
26 DCHECK_EQ(owning_thread_id_, PlatformThread::CurrentId()); 29 DCHECK_EQ(owning_thread_id_, PlatformThread::CurrentId());
27 owned_by_thread_ = false; 30 owned_by_thread_ = false;
28 owning_thread_id_ = static_cast<PlatformThreadId>(0); 31 owning_thread_id_ = static_cast<PlatformThreadId>(0);
29 } 32 }
30 33
31 void Lock::CheckUnheldAndMark() { 34 void Lock::CheckUnheldAndMark() {
32 DCHECK(!owned_by_thread_); 35 DCHECK(!owned_by_thread_);
33 owned_by_thread_ = true; 36 owned_by_thread_ = true;
34 owning_thread_id_ = PlatformThread::CurrentId(); 37 owning_thread_id_ = PlatformThread::CurrentId();
35 } 38 }
36 39
37 #endif // NDEBUG 40 #endif // NDEBUG
OLDNEW
« no previous file with comments | « base/lock.h ('k') | base/lock_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698