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

Unified Diff: base/lock.h

Issue 7660: Move windows specific lock-recursion-counter into windows impl file... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/lock.cc » ('j') | base/lock.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/lock.h
===================================================================
--- base/lock.h (revision 3595)
+++ base/lock.h (working copy)
@@ -8,24 +8,16 @@
#include "base/lock_impl.h"
// A convenient wrapper for an OS specific critical section.
-//
-// NOTE: Although windows critical sections support recursive locks, we do not
-// allow this, and we will commonly fire a DCHECK() if a thread attempts to
-// acquire the lock a second time (while already holding it).
-//
-// Complication: UnitTest for DeathTests catch DCHECK exceptions, so we need
-// to write code assuming DCHECK will throw. This means we need to save any
-// assertable value in a local until we can safely throw.
class Lock {
public:
- Lock();
- ~Lock();
- void Acquire();
- void Release();
+ Lock() : lock_() {}
+ ~Lock() {}
+ void Acquire() { lock_.Lock(); }
+ void Release() { lock_.Unlock(); }
// If the lock is not held, take it and return true. If the lock is already
// held by another thread, immediately return false.
- bool Try();
+ bool Try() { return lock_.Try(); }
// Return the underlying lock implementation.
// TODO(awalker): refactor lock and condition variables so that this is
@@ -33,17 +25,8 @@
LockImpl* lock_impl() { return &lock_; }
private:
- LockImpl lock_; // User-supplied underlying lock implementation.
+ LockImpl lock_; // Platform specific underlying lock implementation.
-#ifndef NDEBUG
- // All private data is implicitly protected by lock_.
- // Be VERY careful to only access members under that lock.
- int32 recursion_count_shadow_;
- bool recursion_used_; // Allow debugging to continued after a DCHECK().
- int32 acquisition_count_; // Number of times lock was acquired.
- int32 contention_count_; // Number of times there was contention.
-#endif // NDEBUG
-
DISALLOW_COPY_AND_ASSIGN(Lock);
};
« no previous file with comments | « no previous file | base/lock.cc » ('j') | base/lock.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698