| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BASE_THREADING_NON_THREAD_SAFE_H_ | |
| 6 #define BASE_THREADING_NON_THREAD_SAFE_H_ | |
| 7 | |
| 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'. | |
| 10 // There is a specific macro to do it: NON_EXPORTED_BASE(), defined in | |
| 11 // compiler_specific.h | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "base/logging.h" | |
| 14 #include "base/threading/non_thread_safe_impl.h" | |
| 15 | |
| 16 namespace base { | |
| 17 | |
| 18 // Do nothing implementation of NonThreadSafe, for release mode. | |
| 19 // | |
| 20 // Note: You should almost always use the NonThreadSafe class to get | |
| 21 // the right version of the class for your build configuration. | |
| 22 class NonThreadSafeDoNothing { | |
| 23 public: | |
| 24 bool CalledOnValidThread() const { | |
| 25 return true; | |
| 26 } | |
| 27 | |
| 28 protected: | |
| 29 ~NonThreadSafeDoNothing() {} | |
| 30 void DetachFromThread() {} | |
| 31 }; | |
| 32 | |
| 33 // DEPRECATED! Use base::SequenceChecker (for thread-safety) or | |
| 34 // base::ThreadChecker (for thread-affinity) -- see their documentation for | |
| 35 // details. Use a checker as a protected member instead of inheriting from | |
| 36 // NonThreadSafe if you need subclasses to have access. | |
| 37 #if DCHECK_IS_ON() | |
| 38 typedef NonThreadSafeImpl NonThreadSafe; | |
| 39 #else | |
| 40 typedef NonThreadSafeDoNothing NonThreadSafe; | |
| 41 #endif // DCHECK_IS_ON() | |
| 42 | |
| 43 } // namespace base | |
| 44 | |
| 45 #endif // BASE_THREADING_NON_THREAD_SAFE_H_ | |
| OLD | NEW |