summaryrefslogtreecommitdiffstats
path: root/base/synchronization
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-14 05:27:08 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-14 05:27:08 +0000
commit8fe650c2437a58ebdbf373a80a93582ff3e5ac48 (patch)
treec3966ff7462a20fbc0049be15e244a9363377af0 /base/synchronization
parentd5c9e4badf70cfe6f0e4e7230f446c702571d2e5 (diff)
downloadchromium_src-8fe650c2437a58ebdbf373a80a93582ff3e5ac48.zip
chromium_src-8fe650c2437a58ebdbf373a80a93582ff3e5ac48.tar.gz
chromium_src-8fe650c2437a58ebdbf373a80a93582ff3e5ac48.tar.bz2
base: Rename OSLockType to NativeHandle in Lock API.
This inline us more with the standard http://en.cppreference.com/w/cpp/thread/mutex. BUG=283054 TEST=base_unittests R=brettw@chromium.org, darin@chromium.org Review URL: https://chromiumcodereview.appspot.com/23753006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223227 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/synchronization')
-rw-r--r--base/synchronization/condition_variable_posix.cc2
-rw-r--r--base/synchronization/condition_variable_win.cc2
-rw-r--r--base/synchronization/lock_impl.h8
-rw-r--r--base/synchronization/lock_impl_posix.cc12
-rw-r--r--base/synchronization/lock_impl_win.cc10
5 files changed, 17 insertions, 17 deletions
diff --git a/base/synchronization/condition_variable_posix.cc b/base/synchronization/condition_variable_posix.cc
index 93b35ed..92b479e 100644
--- a/base/synchronization/condition_variable_posix.cc
+++ b/base/synchronization/condition_variable_posix.cc
@@ -15,7 +15,7 @@
namespace base {
ConditionVariable::ConditionVariable(Lock* user_lock)
- : user_mutex_(user_lock->lock_.os_lock())
+ : user_mutex_(user_lock->lock_.native_handle())
#if !defined(NDEBUG)
, user_lock_(user_lock)
#endif
diff --git a/base/synchronization/condition_variable_win.cc b/base/synchronization/condition_variable_win.cc
index bf0d5f3..927362a 100644
--- a/base/synchronization/condition_variable_win.cc
+++ b/base/synchronization/condition_variable_win.cc
@@ -97,7 +97,7 @@ void WinVistaCondVar::Wait() {
void WinVistaCondVar::TimedWait(const TimeDelta& max_time) {
base::ThreadRestrictions::AssertWaitAllowed();
DWORD timeout = static_cast<DWORD>(max_time.InMilliseconds());
- CRITICAL_SECTION* cs = user_lock_.lock_.os_lock();
+ CRITICAL_SECTION* cs = user_lock_.lock_.native_handle();
#if !defined(NDEBUG)
user_lock_.CheckHeldAndUnmark();
diff --git a/base/synchronization/lock_impl.h b/base/synchronization/lock_impl.h
index 0b04167..42e2f99 100644
--- a/base/synchronization/lock_impl.h
+++ b/base/synchronization/lock_impl.h
@@ -25,9 +25,9 @@ namespace internal {
class BASE_EXPORT LockImpl {
public:
#if defined(OS_WIN)
- typedef CRITICAL_SECTION OSLockType;
+ typedef CRITICAL_SECTION NativeHandle;
#elif defined(OS_POSIX)
- typedef pthread_mutex_t OSLockType;
+ typedef pthread_mutex_t NativeHandle;
#endif
LockImpl();
@@ -47,10 +47,10 @@ class BASE_EXPORT LockImpl {
// Return the native underlying lock.
// TODO(awalker): refactor lock and condition variables so that this is
// unnecessary.
- OSLockType* os_lock() { return &os_lock_; }
+ NativeHandle* native_handle() { return &native_handle_; }
private:
- OSLockType os_lock_;
+ NativeHandle native_handle_;
DISALLOW_COPY_AND_ASSIGN(LockImpl);
};
diff --git a/base/synchronization/lock_impl_posix.cc b/base/synchronization/lock_impl_posix.cc
index 8615876..5619ada 100644
--- a/base/synchronization/lock_impl_posix.cc
+++ b/base/synchronization/lock_impl_posix.cc
@@ -20,34 +20,34 @@ LockImpl::LockImpl() {
DCHECK_EQ(rv, 0) << ". " << strerror(rv);
rv = pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_ERRORCHECK);
DCHECK_EQ(rv, 0) << ". " << strerror(rv);
- rv = pthread_mutex_init(&os_lock_, &mta);
+ rv = pthread_mutex_init(&native_handle_, &mta);
DCHECK_EQ(rv, 0) << ". " << strerror(rv);
rv = pthread_mutexattr_destroy(&mta);
DCHECK_EQ(rv, 0) << ". " << strerror(rv);
#else
// In release, go with the default lock attributes.
- pthread_mutex_init(&os_lock_, NULL);
+ pthread_mutex_init(&native_handle_, NULL);
#endif
}
LockImpl::~LockImpl() {
- int rv = pthread_mutex_destroy(&os_lock_);
+ int rv = pthread_mutex_destroy(&native_handle_);
DCHECK_EQ(rv, 0) << ". " << strerror(rv);
}
bool LockImpl::Try() {
- int rv = pthread_mutex_trylock(&os_lock_);
+ int rv = pthread_mutex_trylock(&native_handle_);
DCHECK(rv == 0 || rv == EBUSY) << ". " << strerror(rv);
return rv == 0;
}
void LockImpl::Lock() {
- int rv = pthread_mutex_lock(&os_lock_);
+ int rv = pthread_mutex_lock(&native_handle_);
DCHECK_EQ(rv, 0) << ". " << strerror(rv);
}
void LockImpl::Unlock() {
- int rv = pthread_mutex_unlock(&os_lock_);
+ int rv = pthread_mutex_unlock(&native_handle_);
DCHECK_EQ(rv, 0) << ". " << strerror(rv);
}
diff --git a/base/synchronization/lock_impl_win.cc b/base/synchronization/lock_impl_win.cc
index bb8a23d..fbc1bdd 100644
--- a/base/synchronization/lock_impl_win.cc
+++ b/base/synchronization/lock_impl_win.cc
@@ -10,26 +10,26 @@ namespace internal {
LockImpl::LockImpl() {
// The second parameter is the spin count, for short-held locks it avoid the
// contending thread from going to sleep which helps performance greatly.
- ::InitializeCriticalSectionAndSpinCount(&os_lock_, 2000);
+ ::InitializeCriticalSectionAndSpinCount(&native_handle_, 2000);
}
LockImpl::~LockImpl() {
- ::DeleteCriticalSection(&os_lock_);
+ ::DeleteCriticalSection(&native_handle_);
}
bool LockImpl::Try() {
- if (::TryEnterCriticalSection(&os_lock_) != FALSE) {
+ if (::TryEnterCriticalSection(&native_handle_) != FALSE) {
return true;
}
return false;
}
void LockImpl::Lock() {
- ::EnterCriticalSection(&os_lock_);
+ ::EnterCriticalSection(&native_handle_);
}
void LockImpl::Unlock() {
- ::LeaveCriticalSection(&os_lock_);
+ ::LeaveCriticalSection(&native_handle_);
}
} // namespace internal