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 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // Example: | 49 // Example: |
50 // class MyClass : public base::NonThreadSafe { | 50 // class MyClass : public base::NonThreadSafe { |
51 // public: | 51 // public: |
52 // void Foo() { | 52 // void Foo() { |
53 // DCHECK(CalledOnValidThread()); | 53 // DCHECK(CalledOnValidThread()); |
54 // ... (do stuff) ... | 54 // ... (do stuff) ... |
55 // } | 55 // } |
56 // } | 56 // } |
57 // | 57 // |
58 // Note that base::ThreadChecker offers identical functionality to | 58 // Note that base::ThreadChecker offers identical functionality to |
59 // NonThreadSafe, but does not require inheritence. In general, it is preferable | 59 // NonThreadSafe, but does not require inheritance. In general, it is preferable |
60 // to have a base::ThreadChecker as a member, rather than inherit from | 60 // to have a base::ThreadChecker as a member, rather than inherit from |
61 // NonThreadSafe. For more details about when to choose one over the other, see | 61 // NonThreadSafe. For more details about when to choose one over the other, see |
62 // the documentation for base::ThreadChecker. | 62 // the documentation for base::ThreadChecker. |
63 #if ENABLE_NON_THREAD_SAFE | 63 #if ENABLE_NON_THREAD_SAFE |
64 typedef NonThreadSafeImpl NonThreadSafe; | 64 typedef NonThreadSafeImpl NonThreadSafe; |
65 #else | 65 #else |
66 typedef NonThreadSafeDoNothing NonThreadSafe; | 66 typedef NonThreadSafeDoNothing NonThreadSafe; |
67 #endif // ENABLE_NON_THREAD_SAFE | 67 #endif // ENABLE_NON_THREAD_SAFE |
68 | 68 |
69 #undef ENABLE_NON_THREAD_SAFE | 69 #undef ENABLE_NON_THREAD_SAFE |
70 | 70 |
71 } // namespace base | 71 } // namespace base |
72 | 72 |
73 #endif // BASE_NON_THREAD_SAFE_H_ | 73 #endif // BASE_NON_THREAD_SAFE_H_ |
OLD | NEW |