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_THREAD_H_ | 5 #ifndef BASE_THREADING_THREAD_H_ |
6 #define BASE_THREADING_THREAD_H_ | 6 #define BASE_THREADING_THREAD_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 explicit Thread(const std::string& name); | 65 explicit Thread(const std::string& name); |
66 | 66 |
67 // Destroys the thread, stopping it if necessary. | 67 // Destroys the thread, stopping it if necessary. |
68 // | 68 // |
69 // NOTE: ALL SUBCLASSES OF Thread MUST CALL Stop() IN THEIR DESTRUCTORS (or | 69 // NOTE: ALL SUBCLASSES OF Thread MUST CALL Stop() IN THEIR DESTRUCTORS (or |
70 // guarantee Stop() is explicitly called before the subclass is destroyed). | 70 // guarantee Stop() is explicitly called before the subclass is destroyed). |
71 // This is required to avoid a data race between the destructor modifying the | 71 // This is required to avoid a data race between the destructor modifying the |
72 // vtable, and the thread's ThreadMain calling the virtual method Run(). It | 72 // vtable, and the thread's ThreadMain calling the virtual method Run(). It |
73 // also ensures that the CleanUp() virtual method is called on the subclass | 73 // also ensures that the CleanUp() virtual method is called on the subclass |
74 // before it is destructed. | 74 // before it is destructed. |
75 virtual ~Thread(); | 75 ~Thread() override; |
76 | 76 |
77 #if defined(OS_WIN) | 77 #if defined(OS_WIN) |
78 // Causes the thread to initialize COM. This must be called before calling | 78 // Causes the thread to initialize COM. This must be called before calling |
79 // Start() or StartWithOptions(). If |use_mta| is false, the thread is also | 79 // Start() or StartWithOptions(). If |use_mta| is false, the thread is also |
80 // started with a TYPE_UI message loop. It is an error to call | 80 // started with a TYPE_UI message loop. It is an error to call |
81 // init_com_with_mta(false) and then StartWithOptions() with any message loop | 81 // init_com_with_mta(false) and then StartWithOptions() with any message loop |
82 // type other than TYPE_UI. | 82 // type other than TYPE_UI. |
83 void init_com_with_mta(bool use_mta) { | 83 void init_com_with_mta(bool use_mta) { |
84 DCHECK(!started_); | 84 DCHECK(!started_); |
85 com_status_ = use_mta ? MTA : STA; | 85 com_status_ = use_mta ? MTA : STA; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 private: | 194 private: |
195 #if defined(OS_WIN) | 195 #if defined(OS_WIN) |
196 enum ComStatus { | 196 enum ComStatus { |
197 NONE, | 197 NONE, |
198 STA, | 198 STA, |
199 MTA, | 199 MTA, |
200 }; | 200 }; |
201 #endif | 201 #endif |
202 | 202 |
203 // PlatformThread::Delegate methods: | 203 // PlatformThread::Delegate methods: |
204 virtual void ThreadMain() override; | 204 void ThreadMain() override; |
205 | 205 |
206 #if defined(OS_WIN) | 206 #if defined(OS_WIN) |
207 // Whether this thread needs to initialize COM, and if so, in what mode. | 207 // Whether this thread needs to initialize COM, and if so, in what mode. |
208 ComStatus com_status_; | 208 ComStatus com_status_; |
209 #endif | 209 #endif |
210 | 210 |
211 // Whether we successfully started the thread. | 211 // Whether we successfully started the thread. |
212 bool started_; | 212 bool started_; |
213 | 213 |
214 // If true, we're in the middle of stopping, and shouldn't access | 214 // If true, we're in the middle of stopping, and shouldn't access |
(...skipping 21 matching lines...) Expand all Loading... |
236 std::string name_; | 236 std::string name_; |
237 | 237 |
238 friend void ThreadQuitHelper(); | 238 friend void ThreadQuitHelper(); |
239 | 239 |
240 DISALLOW_COPY_AND_ASSIGN(Thread); | 240 DISALLOW_COPY_AND_ASSIGN(Thread); |
241 }; | 241 }; |
242 | 242 |
243 } // namespace base | 243 } // namespace base |
244 | 244 |
245 #endif // BASE_THREADING_THREAD_H_ | 245 #endif // BASE_THREADING_THREAD_H_ |
OLD | NEW |