diff options
Diffstat (limited to 'ipc/chromium/src/base/lock_impl.h')
-rw-r--r-- | ipc/chromium/src/base/lock_impl.h | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/ipc/chromium/src/base/lock_impl.h b/ipc/chromium/src/base/lock_impl.h index 67105bd57c..a9a52d4b79 100644 --- a/ipc/chromium/src/base/lock_impl.h +++ b/ipc/chromium/src/base/lock_impl.h @@ -1,11 +1,11 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef BASE_LOCK_IMPL_H_ #define BASE_LOCK_IMPL_H_ +#include "base/basictypes.h" #include "build/build_config.h" #if defined(OS_WIN) @@ -14,8 +14,8 @@ #include <pthread.h> #endif -#include "base/basictypes.h" -#include "base/platform_thread.h" +namespace base { +namespace internal { // This class implements the underlying platform-specific spin-lock mechanism // used for the Lock class. Most users should not use LockImpl directly, but @@ -23,9 +23,9 @@ class LockImpl { public: #if defined(OS_WIN) - typedef CRITICAL_SECTION OSLockType; + using NativeHandle = SRWLOCK; #elif defined(OS_POSIX) - typedef pthread_mutex_t OSLockType; + using NativeHandle = pthread_mutex_t; #endif LockImpl(); @@ -42,37 +42,23 @@ class LockImpl { // a successful call to Try, or a call to Lock. void Unlock(); - // Debug-only method that will DCHECK() if the lock is not acquired by the - // current thread. In non-debug builds, no check is performed. - // Because linux and mac condition variables modify the underlyning lock - // through the os_lock() method, runtime assertions can not be done on those - // builds. -#if defined(NDEBUG) || !defined(OS_WIN) - void AssertAcquired() const {} -#else - void AssertAcquired() const; -#endif - - // Return the native underlying lock. Not supported for Windows builds. + // Return the native underlying lock. // TODO(awalker): refactor lock and condition variables so that this is // unnecessary. -#if !defined(OS_WIN) - OSLockType* os_lock() { return &os_lock_; } + NativeHandle* native_handle() { return &native_handle_; } + +#if defined(OS_POSIX) + // Whether this lock will attempt to use priority inheritance. + static bool PriorityInheritanceAvailable(); #endif private: - OSLockType os_lock_; - -#if !defined(NDEBUG) && defined(OS_WIN) - // All private data is implicitly protected by lock_. - // Be VERY careful to only access members under that lock. - PlatformThreadId owning_thread_id_; - int32_t recursion_count_shadow_; - bool recursion_used_; // Allow debugging to continued after a DCHECK(). -#endif // NDEBUG + NativeHandle native_handle_; DISALLOW_COPY_AND_ASSIGN(LockImpl); }; +} // namespace internal +} // namespace base #endif // BASE_LOCK_IMPL_H_ |