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

Unified Diff: base/synchronization/lock_impl.h

Issue 2949953002: Make LockImpl::Unlock available for inlining (Closed)
Patch Set: Created 3 years, 6 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/synchronization/lock_impl_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/synchronization/lock_impl.h
diff --git a/base/synchronization/lock_impl.h b/base/synchronization/lock_impl.h
index 603585a05041764e20c41c17f57504130ba82110..880e70db36c106924162c98a3350af3c5866dfb0 100644
--- a/base/synchronization/lock_impl.h
+++ b/base/synchronization/lock_impl.h
@@ -6,12 +6,14 @@
#define BASE_SYNCHRONIZATION_LOCK_IMPL_H_
#include "base/base_export.h"
+#include "base/logging.h"
#include "base/macros.h"
#include "build/build_config.h"
#if defined(OS_WIN)
#include <windows.h>
#elif defined(OS_POSIX)
+#include <errno.h>
#include <pthread.h>
#endif
@@ -26,7 +28,7 @@ class BASE_EXPORT LockImpl {
#if defined(OS_WIN)
using NativeHandle = SRWLOCK;
#elif defined(OS_POSIX)
- using NativeHandle = pthread_mutex_t;
+ using NativeHandle = pthread_mutex_t;
#endif
LockImpl();
@@ -41,7 +43,7 @@ class BASE_EXPORT LockImpl {
// Release the lock. This must only be called by the lock's holder: after
// a successful call to Try, or a call to Lock.
- void Unlock();
+ inline void Unlock();
// Return the native underlying lock.
// TODO(awalker): refactor lock and condition variables so that this is
@@ -59,6 +61,17 @@ class BASE_EXPORT LockImpl {
DISALLOW_COPY_AND_ASSIGN(LockImpl);
};
+#if defined(OS_WIN)
+void LockImpl::Unlock() {
+ ::ReleaseSRWLockExclusive(&native_handle_);
+}
+#elif defined(OS_POSIX)
+void LockImpl::Unlock() {
+ int rv = pthread_mutex_unlock(&native_handle_);
+ DCHECK_EQ(rv, 0) << ". " << strerror(rv);
+}
+#endif
+
} // namespace internal
} // namespace base
« no previous file with comments | « no previous file | base/synchronization/lock_impl_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698