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 #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(); |
| 69 } |
| 70 #endif |
| 71 |
64 #if defined(OS_POSIX) || defined(OS_WIN) | 72 #if defined(OS_POSIX) || defined(OS_WIN) |
65 // Both Windows and POSIX implementations of ConditionVariable need to be | 73 // Both Windows and POSIX implementations of ConditionVariable need to be |
66 // able to see our lock and tweak our debugging counters, as they release and | 74 // able to see our lock and tweak our debugging counters, as they release and |
67 // acquire locks inside of their condition variable APIs. | 75 // acquire locks inside of their condition variable APIs. |
68 friend class ConditionVariable; | 76 friend class ConditionVariable; |
69 #endif | 77 #endif |
70 | 78 |
71 private: | 79 private: |
72 #if DCHECK_IS_ON() | 80 #if DCHECK_IS_ON() |
73 // Members and routines taking care of locks assertions. | 81 // Members and routines taking care of locks assertions. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } | 135 } |
128 | 136 |
129 private: | 137 private: |
130 Lock& lock_; | 138 Lock& lock_; |
131 DISALLOW_COPY_AND_ASSIGN(AutoUnlock); | 139 DISALLOW_COPY_AND_ASSIGN(AutoUnlock); |
132 }; | 140 }; |
133 | 141 |
134 } // namespace base | 142 } // namespace base |
135 | 143 |
136 #endif // BASE_SYNCHRONIZATION_LOCK_H_ | 144 #endif // BASE_SYNCHRONIZATION_LOCK_H_ |
OLD | NEW |