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); |
}; |