summaryrefslogtreecommitdiffstats
path: root/base/lock.cc
diff options
context:
space:
mode:
authorjar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-21 23:37:02 +0000
committerjar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-21 23:37:02 +0000
commit3cdb6a704df743d914e67850f909b497b7e5ad5c (patch)
treeb343dae90fa83293846cfa1a58a6d2904fb81271 /base/lock.cc
parent68c245d774ca1ef9c9b11ea352ed22ac8c5f939c (diff)
downloadchromium_src-3cdb6a704df743d914e67850f909b497b7e5ad5c.zip
chromium_src-3cdb6a704df743d914e67850f909b497b7e5ad5c.tar.gz
chromium_src-3cdb6a704df743d914e67850f909b497b7e5ad5c.tar.bz2
Move windows specific lock-recursion-counter into windows impl file
Unix implementation of lock leaks the underlying lock_impl_ member so that the condition variable implementation can directly acquire and release the lock (without going through our abstract interface). This causse the recursion counter to become incorrect on such platforms. Windows uses an implementation of condition variables that uses our abstract interface, and hence is the only implementation that can track the recursion count (and besides... windows is the only platform that currently allows recursive (multiple) acquisitions of a lock by a single thread. I'll work on gracefully removing the depricated lock.cc after I've landed this change. r=cpu Review URL: http://codereview.chromium.org/7660 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3703 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/lock.cc')
-rw-r--r--base/lock.cc70
1 files changed, 1 insertions, 69 deletions
diff --git a/base/lock.cc b/base/lock.cc
index dc17c47..9ff963b 100644
--- a/base/lock.cc
+++ b/base/lock.cc
@@ -2,74 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Provide place to put profiling methods for the
// Lock class.
-// The Lock class is used everywhere, and hence any changes
-// to lock.h tend to require a complete rebuild. To facilitate
-// profiler development, all the profiling methods are listed
-// here.
-#include "base/lock.h"
-#include "base/logging.h"
-
-#ifndef NDEBUG
-Lock::Lock()
- : lock_(),
- recursion_count_shadow_(0),
- recursion_used_(false),
- acquisition_count_(0),
- contention_count_(0) {
-}
-#else // NDEBUG
-Lock::Lock()
- : lock_() {
-}
-#endif // NDEBUG
-
-Lock::~Lock() {
-}
-
-void Lock::Acquire() {
-#ifdef NDEBUG
- lock_.Lock();
-#else // NDEBUG
- if (!lock_.Try()) {
- // We have contention.
- lock_.Lock();
- contention_count_++;
- }
- // ONLY access data after locking.
- recursion_count_shadow_++;
- acquisition_count_++;
- if (2 == recursion_count_shadow_ && !recursion_used_) {
- recursion_used_ = true;
- // TODO(jar): this is causing failures in ThreadTest.Restart and
- // ChromeThreadTest.Get on Linux.
- // DCHECK(false); // Catch accidental redundant lock acquisition.
- }
-#endif // NDEBUG
-}
-
-void Lock::Release() {
-#ifndef NDEBUG
- --recursion_count_shadow_; // ONLY access while lock is still held.
- DCHECK(0 <= recursion_count_shadow_);
-#endif // NDEBUG
- lock_.Unlock();
-}
-
-bool Lock::Try() {
- if (lock_.Try()) {
-#ifndef NDEBUG
- recursion_count_shadow_++;
- acquisition_count_++;
- if (2 == recursion_count_shadow_ && !recursion_used_) {
- recursion_used_ = true;
- DCHECK(false); // Catch accidental redundant lock acquisition.
- }
-#endif
- return true;
- } else {
- return false;
- }
-}
+// Depricated file. See lock_impl_*.cc for platform specific versions.