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

Unified Diff: base/synchronization/lock.h

Issue 2178503003: Add PTHREAD_PRIO_INHERIT Locks for Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Feedback Created 4 years, 5 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.h » ('j') | base/synchronization/lock_impl.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/synchronization/lock.h
diff --git a/base/synchronization/lock.h b/base/synchronization/lock.h
index fbf6cef76911c80332da1524beeb23fd14737917..fb15c66004457f91ef19080e6d7ff7a38c1c09f1 100644
--- a/base/synchronization/lock.h
+++ b/base/synchronization/lock.h
@@ -14,6 +14,22 @@
namespace base {
+#if defined(OS_POSIX)
danakj 2016/07/27 22:47:53 Why is this behind OS_POSIX? I'd expect it to just
robliao 2016/07/28 20:06:09 The intention was to only have this in POSIX since
danakj 2016/07/28 20:49:03 I see. It's just that to check this now you will h
robliao 2016/07/28 21:08:38 My sense is that code will fall under one of two c
+
+// Determines which platforms can consider using priority inheritance locks. If
+// priority inheritance is possible, it does not necessarily mean it's
+// available. Lock::PriorityInheritanceAvailable must still be checked.
+// If you do not require the conditional inclusion at compile time,
+// simply call Lock::PriorityInheritanceAvailable, which will provide the same
+// result.
+#if defined(OS_NACL) || defined(OS_ANDROID)
+#define PRIORITY_INHERITANCE_LOCKS_POSSIBLE() 0
+#else
+#define PRIORITY_INHERITANCE_LOCKS_POSSIBLE() 1
+#endif
+
+#endif
+
// A convenient wrapper for an OS specific critical section. The only real
// intelligence in this class is in debug mode for the support for the
// AssertAcquired() method.
@@ -61,6 +77,14 @@ class BASE_EXPORT Lock {
void AssertAcquired() const;
#endif // DCHECK_IS_ON()
+#if defined(OS_POSIX)
danakj 2016/07/27 22:47:53 And why is this behind OS_POSIX instead of behind
robliao 2016/07/28 20:06:09 See above. This is intended to be the runtime chec
+ // Whether this platform has priority inheritance available. All locks will
+ // attempt to use the priority inheritance version if available.
+ static bool PriorityInheritanceAvailable() {
+ return internal::LockImpl::PriorityInheritanceAvailable();
+ }
fdoray 2016/07/28 14:38:36 Could this be available on all platforms and calle
robliao 2016/07/28 20:06:09 The #if is still necessary if code won't compile.
+#endif
+
#if defined(OS_POSIX) || defined(OS_WIN)
// Both Windows and POSIX implementations of ConditionVariable need to be
// able to see our lock and tweak our debugging counters, as they release and
« no previous file with comments | « no previous file | base/synchronization/lock_impl.h » ('j') | base/synchronization/lock_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698