OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 PPAPI_UTILITY_THREAD_SAFE_THREAD_TRAITS_H_ | 5 #ifndef PPAPI_UTILITY_THREAD_SAFE_THREAD_TRAITS_H_ |
6 #define PPAPI_UTILITY_THREAD_SAFE_THREAD_TRAITS_H_ | 6 #define PPAPI_UTILITY_THREAD_SAFE_THREAD_TRAITS_H_ |
7 | 7 |
8 #include "ppapi/cpp/logging.h" | 8 #include "ppapi/cpp/logging.h" |
9 #include "ppapi/cpp/module.h" | 9 #include "ppapi/cpp/module.h" |
10 #include "ppapi/utility/threading/lock.h" | 10 #include "ppapi/utility/threading/lock.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 private: | 112 private: |
113 int32_t ref_; | 113 int32_t ref_; |
114 #ifndef NDEBUG | 114 #ifndef NDEBUG |
115 bool is_main_thread_; | 115 bool is_main_thread_; |
116 #endif | 116 #endif |
117 }; | 117 }; |
118 | 118 |
119 /// A simple object that acts like a lock but does nothing. | 119 /// A simple object that acts like a lock but does nothing. |
120 /// | 120 /// |
121 /// MStrong>Note:</strong> in Debug mode, it checks that it is either | 121 /// <strong>Note:</strong> in Debug mode, it checks that it is either |
122 /// called on the main thread, or always called on another thread. It also | 122 /// called on the main thread, or always called on another thread. It also |
123 /// asserts that the caller does not recursively lock. | 123 /// asserts that the caller does not recursively lock. |
124 class Lock { | 124 class Lock { |
125 public: | 125 public: |
126 Lock() { | 126 Lock() { |
127 #ifndef NDEBUG | 127 #ifndef NDEBUG |
128 is_main_thread_ = Module::Get()->core()->IsMainThread(); | 128 is_main_thread_ = Module::Get()->core()->IsMainThread(); |
129 lock_held_ = false; | 129 lock_held_ = false; |
130 #endif | 130 #endif |
131 } | 131 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 169 } |
170 | 170 |
171 private: | 171 private: |
172 Lock& lock_; | 172 Lock& lock_; |
173 }; | 173 }; |
174 }; | 174 }; |
175 | 175 |
176 } // namespace pp | 176 } // namespace pp |
177 | 177 |
178 #endif // PPAPI_UTILITY_THREAD_SAFE_THREAD_TRAITS_H_ | 178 #endif // PPAPI_UTILITY_THREAD_SAFE_THREAD_TRAITS_H_ |
OLD | NEW |