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/synchronization/lock_impl.h" | 9 #include "base/synchronization/lock_impl.h" |
10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // Members and routines taking care of locks assertions. | 73 // Members and routines taking care of locks assertions. |
74 // Note that this checks for recursive locks and allows them | 74 // Note that this checks for recursive locks and allows them |
75 // if the variable is set. This is allowed by the underlying implementation | 75 // if the variable is set. This is allowed by the underlying implementation |
76 // on windows but not on Posix, so we're doing unneeded checks on Posix. | 76 // on windows but not on Posix, so we're doing unneeded checks on Posix. |
77 // It's worth it to share the code. | 77 // It's worth it to share the code. |
78 void CheckHeldAndUnmark(); | 78 void CheckHeldAndUnmark(); |
79 void CheckUnheldAndMark(); | 79 void CheckUnheldAndMark(); |
80 | 80 |
81 // All private data is implicitly protected by lock_. | 81 // All private data is implicitly protected by lock_. |
82 // Be VERY careful to only access members under that lock. | 82 // Be VERY careful to only access members under that lock. |
83 | 83 base::PlatformThreadRef owning_thread_ref_; |
84 // Determines validity of owning_thread_id_. Needed as we don't have | |
85 // a null owning_thread_id_ value. | |
86 bool owned_by_thread_; | |
87 base::PlatformThreadId owning_thread_id_; | |
88 #endif // NDEBUG | 84 #endif // NDEBUG |
89 | 85 |
90 // Platform specific underlying lock implementation. | 86 // Platform specific underlying lock implementation. |
91 internal::LockImpl lock_; | 87 internal::LockImpl lock_; |
92 | 88 |
93 DISALLOW_COPY_AND_ASSIGN(Lock); | 89 DISALLOW_COPY_AND_ASSIGN(Lock); |
94 }; | 90 }; |
95 | 91 |
96 // A helper class that acquires the given Lock while the AutoLock is in scope. | 92 // A helper class that acquires the given Lock while the AutoLock is in scope. |
97 class AutoLock { | 93 class AutoLock { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 127 } |
132 | 128 |
133 private: | 129 private: |
134 Lock& lock_; | 130 Lock& lock_; |
135 DISALLOW_COPY_AND_ASSIGN(AutoUnlock); | 131 DISALLOW_COPY_AND_ASSIGN(AutoUnlock); |
136 }; | 132 }; |
137 | 133 |
138 } // namespace base | 134 } // namespace base |
139 | 135 |
140 #endif // BASE_SYNCHRONIZATION_LOCK_H_ | 136 #endif // BASE_SYNCHRONIZATION_LOCK_H_ |
OLD | NEW |