Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_SYNCHRONIZATION_LOCK_H_ | 5 #ifndef BASE_SYNCHRONIZATION_LOCK_H_ |
| 6 #define BASE_SYNCHRONIZATION_LOCK_H_ | 6 #define BASE_SYNCHRONIZATION_LOCK_H_ |
| 7 | 7 |
| 8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 bool rv = lock_.Try(); | 54 bool rv = lock_.Try(); |
| 55 if (rv) { | 55 if (rv) { |
| 56 CheckUnheldAndMark(); | 56 CheckUnheldAndMark(); |
| 57 } | 57 } |
| 58 return rv; | 58 return rv; |
| 59 } | 59 } |
| 60 | 60 |
| 61 void AssertAcquired() const; | 61 void AssertAcquired() const; |
| 62 #endif // DCHECK_IS_ON() | 62 #endif // DCHECK_IS_ON() |
| 63 | 63 |
| 64 // Whether it is safe to use a Lock from different thread priorities (i.e. | |
| 65 // there won't be priority inversion for an extended period of time). | |
| 66 static bool IsSafeWithMultipleThreadPriorities() { | |
|
robliao
2016/08/03 18:02:10
I would go with HandlesMultipleThreadPriorities. S
fdoray
2016/08/03 18:34:48
Done.
| |
| 64 #if defined(OS_POSIX) | 67 #if defined(OS_POSIX) |
| 65 // Whether this platform has priority inheritance available. All locks will | |
| 66 // attempt to use the priority inheritance version if available. | |
| 67 static bool PriorityInheritanceAvailable() { | |
| 68 return internal::LockImpl::PriorityInheritanceAvailable(); | 68 return internal::LockImpl::PriorityInheritanceAvailable(); |
| 69 #else | |
| 70 return true; | |
|
gab
2016/08/03 18:04:57
Add a comment about why that's true on Windows (su
fdoray
2016/08/03 18:34:48
Done.
| |
| 71 #endif | |
| 69 } | 72 } |
| 70 #endif | |
| 71 | 73 |
| 72 #if defined(OS_POSIX) || defined(OS_WIN) | 74 #if defined(OS_POSIX) || defined(OS_WIN) |
| 73 // Both Windows and POSIX implementations of ConditionVariable need to be | 75 // Both Windows and POSIX implementations of ConditionVariable need to be |
| 74 // able to see our lock and tweak our debugging counters, as they release and | 76 // able to see our lock and tweak our debugging counters, as they release and |
| 75 // acquire locks inside of their condition variable APIs. | 77 // acquire locks inside of their condition variable APIs. |
| 76 friend class ConditionVariable; | 78 friend class ConditionVariable; |
| 77 #endif | 79 #endif |
| 78 | 80 |
| 79 private: | 81 private: |
| 80 #if DCHECK_IS_ON() | 82 #if DCHECK_IS_ON() |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 } | 137 } |
| 136 | 138 |
| 137 private: | 139 private: |
| 138 Lock& lock_; | 140 Lock& lock_; |
| 139 DISALLOW_COPY_AND_ASSIGN(AutoUnlock); | 141 DISALLOW_COPY_AND_ASSIGN(AutoUnlock); |
| 140 }; | 142 }; |
| 141 | 143 |
| 142 } // namespace base | 144 } // namespace base |
| 143 | 145 |
| 144 #endif // BASE_SYNCHRONIZATION_LOCK_H_ | 146 #endif // BASE_SYNCHRONIZATION_LOCK_H_ |
| OLD | NEW |