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

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

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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/synchronization/lock.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) 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/synchronization/lock_impl.h" 9 #include "base/synchronization/lock_impl.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
(...skipping 14 matching lines...) Expand all
25 // If the lock is not held, take it and return true. If the lock is already 25 // If the lock is not held, take it and return true. If the lock is already
26 // held by another thread, immediately return false. This must not be called 26 // held by another thread, immediately return false. This must not be called
27 // by a thread already holding the lock (what happens is undefined and an 27 // by a thread already holding the lock (what happens is undefined and an
28 // assertion may fail). 28 // assertion may fail).
29 bool Try() { return lock_.Try(); } 29 bool Try() { return lock_.Try(); }
30 30
31 // Null implementation if not debug. 31 // Null implementation if not debug.
32 void AssertAcquired() const {} 32 void AssertAcquired() const {}
33 #else 33 #else
34 Lock(); 34 Lock();
35 ~Lock() {} 35 ~Lock();
36 36
37 // NOTE: Although windows critical sections support recursive locks, we do not 37 // NOTE: Although windows critical sections support recursive locks, we do not
38 // allow this, and we will commonly fire a DCHECK() if a thread attempts to 38 // allow this, and we will commonly fire a DCHECK() if a thread attempts to
39 // acquire the lock a second time (while already holding it). 39 // acquire the lock a second time (while already holding it).
40 void Acquire() { 40 void Acquire() {
41 lock_.Lock(); 41 lock_.Lock();
42 CheckUnheldAndMark(); 42 CheckUnheldAndMark();
43 } 43 }
44 void Release() { 44 void Release() {
45 CheckHeldAndUnmark(); 45 CheckHeldAndUnmark();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 private: 127 private:
128 Lock& lock_; 128 Lock& lock_;
129 DISALLOW_COPY_AND_ASSIGN(AutoUnlock); 129 DISALLOW_COPY_AND_ASSIGN(AutoUnlock);
130 }; 130 };
131 131
132 } // namespace base 132 } // namespace base
133 133
134 #endif // BASE_SYNCHRONIZATION_LOCK_H_ 134 #endif // BASE_SYNCHRONIZATION_LOCK_H_
OLDNEW
« no previous file with comments | « no previous file | base/synchronization/lock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698