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 BASE_THREADING_NON_THREAD_SAFE_H_ | 5 #ifndef BASE_THREADING_NON_THREAD_SAFE_H_ |
6 #define BASE_THREADING_NON_THREAD_SAFE_H_ | 6 #define BASE_THREADING_NON_THREAD_SAFE_H_ |
7 | 7 |
8 // Classes deriving from NonThreadSafe may need to suppress MSVC warning 4275: | 8 // Classes deriving from NonThreadSafe may need to suppress MSVC warning 4275: |
9 // non dll-interface class 'Bar' used as base for dll-interface class 'Foo'. | 9 // non dll-interface class 'Bar' used as base for dll-interface class 'Foo'. |
10 // There is a specific macro to do it: NON_EXPORTED_BASE(), defined in | 10 // There is a specific macro to do it: NON_EXPORTED_BASE(), defined in |
11 // compiler_specific.h | 11 // compiler_specific.h |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 | 13 |
14 // See comment at top of thread_checker.h | 14 // See comment at top of thread_checker.h |
15 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) | 15 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) |
16 #define ENABLE_NON_THREAD_SAFE 1 | 16 #define ENABLE_NON_THREAD_SAFE 1 |
17 #else | 17 #else |
18 #define ENABLE_NON_THREAD_SAFE 0 | 18 #define ENABLE_NON_THREAD_SAFE 0 |
19 #endif | 19 #endif |
20 | 20 |
21 #if ENABLE_NON_THREAD_SAFE | |
22 #include "base/threading/non_thread_safe_impl.h" | 21 #include "base/threading/non_thread_safe_impl.h" |
23 #endif | |
24 | 22 |
25 namespace base { | 23 namespace base { |
26 | 24 |
27 // Do nothing implementation of NonThreadSafe, for release mode. | 25 // Do nothing implementation of NonThreadSafe, for release mode. |
28 // | 26 // |
29 // Note: You should almost always use the NonThreadSafe class to get | 27 // Note: You should almost always use the NonThreadSafe class to get |
30 // the right version of the class for your build configuration. | 28 // the right version of the class for your build configuration. |
31 class NonThreadSafeDoNothing { | 29 class NonThreadSafeDoNothing { |
32 public: | 30 public: |
33 bool CalledOnValidThread() const { | 31 bool CalledOnValidThread() const { |
(...skipping 29 matching lines...) Expand all Loading... |
63 #if ENABLE_NON_THREAD_SAFE | 61 #if ENABLE_NON_THREAD_SAFE |
64 typedef NonThreadSafeImpl NonThreadSafe; | 62 typedef NonThreadSafeImpl NonThreadSafe; |
65 #else | 63 #else |
66 typedef NonThreadSafeDoNothing NonThreadSafe; | 64 typedef NonThreadSafeDoNothing NonThreadSafe; |
67 #endif // ENABLE_NON_THREAD_SAFE | 65 #endif // ENABLE_NON_THREAD_SAFE |
68 | 66 |
69 #undef ENABLE_NON_THREAD_SAFE | 67 #undef ENABLE_NON_THREAD_SAFE |
70 | 68 |
71 } // namespace base | 69 } // namespace base |
72 | 70 |
73 #endif // BASE_NON_THREAD_SAFE_H_ | 71 #endif // BASE_THREADING_NON_THREAD_SAFE_H_ |
OLD | NEW |