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_THREADING_NON_THREAD_SAFE_IMPL_H_ | 5 #ifndef BASE_THREADING_NON_THREAD_SAFE_IMPL_H_ |
6 #define BASE_THREADING_NON_THREAD_SAFE_IMPL_H_ | 6 #define BASE_THREADING_NON_THREAD_SAFE_IMPL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/base_api.h" | 9 #include "base/base_export.h" |
10 #include "base/threading/thread_checker_impl.h" | 10 #include "base/threading/thread_checker_impl.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 | 13 |
14 // Full implementation of NonThreadSafe, for debug mode or for occasional | 14 // Full implementation of NonThreadSafe, for debug mode or for occasional |
15 // temporary use in release mode e.g. when you need to CHECK on a thread | 15 // temporary use in release mode e.g. when you need to CHECK on a thread |
16 // bug that only occurs in the wild. | 16 // bug that only occurs in the wild. |
17 // | 17 // |
18 // Note: You should almost always use the NonThreadSafe class to get | 18 // Note: You should almost always use the NonThreadSafe class to get |
19 // the right version of the class for your build configuration. | 19 // the right version of the class for your build configuration. |
20 class BASE_API NonThreadSafeImpl { | 20 class BASE_EXPORT NonThreadSafeImpl { |
21 public: | 21 public: |
22 ~NonThreadSafeImpl(); | 22 ~NonThreadSafeImpl(); |
23 | 23 |
24 bool CalledOnValidThread() const; | 24 bool CalledOnValidThread() const; |
25 | 25 |
26 protected: | 26 protected: |
27 // Changes the thread that is checked for in CalledOnValidThread. The next | 27 // Changes the thread that is checked for in CalledOnValidThread. The next |
28 // call to CalledOnValidThread will attach this class to a new thread. It is | 28 // call to CalledOnValidThread will attach this class to a new thread. It is |
29 // up to the NonThreadSafe derived class to decide to expose this or not. | 29 // up to the NonThreadSafe derived class to decide to expose this or not. |
30 // This may be useful when an object may be created on one thread and then | 30 // This may be useful when an object may be created on one thread and then |
31 // used exclusively on another thread. | 31 // used exclusively on another thread. |
32 void DetachFromThread(); | 32 void DetachFromThread(); |
33 | 33 |
34 private: | 34 private: |
35 ThreadCheckerImpl thread_checker_; | 35 ThreadCheckerImpl thread_checker_; |
36 }; | 36 }; |
37 | 37 |
38 } // namespace base | 38 } // namespace base |
39 | 39 |
40 #endif // BASE_THREADING_NON_THREAD_SAFE_IMPL_H_ | 40 #endif // BASE_THREADING_NON_THREAD_SAFE_IMPL_H_ |
OLD | NEW |