Chromium Code Reviews| Index: base/synchronization/lock.h |
| diff --git a/base/synchronization/lock.h b/base/synchronization/lock.h |
| index c2680cbcc8a145be5ce3556a76e071e595997d7a..27a2b02c95407eff3465cd6f12c9098e1c759e0e 100644 |
| --- a/base/synchronization/lock.h |
| +++ b/base/synchronization/lock.h |
| @@ -61,13 +61,21 @@ class BASE_EXPORT Lock { |
| void AssertAcquired() const; |
| #endif // DCHECK_IS_ON() |
| + // Whether Lock mitigates priority inversion when used from different thread |
|
robliao
2016/08/03 19:30:07
One more nit: Since we're generalizing this, I wou
fdoray
2016/08/03 19:32:10
Done.
|
| + // priorities. Priority inversion is mitigated by allowing a thread that holds |
| + // a Lock to run when higher priority threads try to acquire it. |
|
gab
2016/08/03 19:36:25
I think the second sentence is specific to the imp
fdoray
2016/08/03 19:46:25
Done.
|
| + static bool HandlesMultipleThreadPriorities() { |
| #if defined(OS_POSIX) |
| - // 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(); |
| - } |
| +#elif defined(OS_WIN) |
| + // Windows mitigates priority inversion by randomly boosting the priority of |
| + // ready threads. |
| + // https://msdn.microsoft.com/library/windows/desktop/ms684831.aspx |
| + return true; |
| +#else |
| +#error Must specify if the lock handles multiple thread priorities. |
|
gab
2016/08/03 19:36:25
#error Unsupported platform
is sufficient IMO
fdoray
2016/08/03 19:46:25
Done.
|
| #endif |
| + } |
| #if defined(OS_POSIX) || defined(OS_WIN) |
| // Both Windows and POSIX implementations of ConditionVariable need to be |