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

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

Issue 1864323002: Migrate from CRITICAL_SECTION to SRWLOCK (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cv
Patch Set: Update Comment Created 4 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 unified diff | Download patch
« no previous file with comments | « base/synchronization/condition_variable_win.cc ('k') | base/synchronization/lock_impl.h » ('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) 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 #ifndef BASE_SYNCHRONIZATION_LOCK_H_ 5 #ifndef BASE_SYNCHRONIZATION_LOCK_H_
6 #define BASE_SYNCHRONIZATION_LOCK_H_ 6 #define BASE_SYNCHRONIZATION_LOCK_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 20 matching lines...) Expand all
31 // by a thread already holding the lock (what happens is undefined and an 31 // by a thread already holding the lock (what happens is undefined and an
32 // assertion may fail). 32 // assertion may fail).
33 bool Try() { return lock_.Try(); } 33 bool Try() { return lock_.Try(); }
34 34
35 // Null implementation if not debug. 35 // Null implementation if not debug.
36 void AssertAcquired() const {} 36 void AssertAcquired() const {}
37 #else 37 #else
38 Lock(); 38 Lock();
39 ~Lock(); 39 ~Lock();
40 40
41 // NOTE: Although windows critical sections support recursive locks, we do not 41 // NOTE: We do not permit recursive locks and will commonly fire a DCHECK() if
42 // allow this, and we will commonly fire a DCHECK() if a thread attempts to 42 // a thread attempts to acquire the lock a second time (while already holding
43 // acquire the lock a second time (while already holding it). 43 // it).
44 void Acquire() { 44 void Acquire() {
45 lock_.Lock(); 45 lock_.Lock();
46 CheckUnheldAndMark(); 46 CheckUnheldAndMark();
47 } 47 }
48 void Release() { 48 void Release() {
49 CheckHeldAndUnmark(); 49 CheckHeldAndUnmark();
50 lock_.Unlock(); 50 lock_.Unlock();
51 } 51 }
52 52
53 bool Try() { 53 bool Try() {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 127 }
128 128
129 private: 129 private:
130 Lock& lock_; 130 Lock& lock_;
131 DISALLOW_COPY_AND_ASSIGN(AutoUnlock); 131 DISALLOW_COPY_AND_ASSIGN(AutoUnlock);
132 }; 132 };
133 133
134 } // namespace base 134 } // namespace base
135 135
136 #endif // BASE_SYNCHRONIZATION_LOCK_H_ 136 #endif // BASE_SYNCHRONIZATION_LOCK_H_
OLDNEW
« no previous file with comments | « base/synchronization/condition_variable_win.cc ('k') | base/synchronization/lock_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698