| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 237 |
| 238 // Called just after the message loop ends | 238 // Called just after the message loop ends |
| 239 virtual void CleanUp() {} | 239 virtual void CleanUp() {} |
| 240 | 240 |
| 241 static void SetThreadWasQuitProperly(bool flag); | 241 static void SetThreadWasQuitProperly(bool flag); |
| 242 static bool GetThreadWasQuitProperly(); | 242 static bool GetThreadWasQuitProperly(); |
| 243 | 243 |
| 244 // Bind this Thread to an existing MessageLoop instead of starting a new one. | 244 // Bind this Thread to an existing MessageLoop instead of starting a new one. |
| 245 void SetMessageLoop(MessageLoop* message_loop); | 245 void SetMessageLoop(MessageLoop* message_loop); |
| 246 | 246 |
| 247 // True only if |message_loop_| was externally provided by |SetMessageLoop()| |
| 248 // in which case this Thread has no underlying |thread_| and should merely |
| 249 // drop |message_loop_| on Stop(). |
| 250 bool using_external_message_loop_ = false; |
| 251 |
| 247 private: | 252 private: |
| 248 #if defined(OS_WIN) | 253 #if defined(OS_WIN) |
| 249 enum ComStatus { | 254 enum ComStatus { |
| 250 NONE, | 255 NONE, |
| 251 STA, | 256 STA, |
| 252 MTA, | 257 MTA, |
| 253 }; | 258 }; |
| 254 #endif | 259 #endif |
| 255 | 260 |
| 256 // PlatformThread::Delegate methods: | 261 // PlatformThread::Delegate methods: |
| (...skipping 27 matching lines...) Expand all Loading... |
| 284 // The thread's id once it has started. | 289 // The thread's id once it has started. |
| 285 PlatformThreadId id_ = kInvalidThreadId; | 290 PlatformThreadId id_ = kInvalidThreadId; |
| 286 // Protects |id_| which must only be read while it's signaled. | 291 // Protects |id_| which must only be read while it's signaled. |
| 287 mutable WaitableEvent id_event_; | 292 mutable WaitableEvent id_event_; |
| 288 | 293 |
| 289 // The thread's MessageLoop and RunLoop. Valid only while the thread is alive. | 294 // The thread's MessageLoop and RunLoop. Valid only while the thread is alive. |
| 290 // Set by the created thread. | 295 // Set by the created thread. |
| 291 MessageLoop* message_loop_ = nullptr; | 296 MessageLoop* message_loop_ = nullptr; |
| 292 RunLoop* run_loop_ = nullptr; | 297 RunLoop* run_loop_ = nullptr; |
| 293 | 298 |
| 294 // True only if |message_loop_| was externally provided by |SetMessageLoop()| | |
| 295 // in which case this Thread has no underlying |thread_| and should merely | |
| 296 // drop |message_loop_| on Stop(). | |
| 297 bool using_external_message_loop_ = false; | |
| 298 | |
| 299 // Stores Options::timer_slack_ until the message loop has been bound to | 299 // Stores Options::timer_slack_ until the message loop has been bound to |
| 300 // a thread. | 300 // a thread. |
| 301 TimerSlack message_loop_timer_slack_ = TIMER_SLACK_NONE; | 301 TimerSlack message_loop_timer_slack_ = TIMER_SLACK_NONE; |
| 302 | 302 |
| 303 // The name of the thread. Used for debugging purposes. | 303 // The name of the thread. Used for debugging purposes. |
| 304 const std::string name_; | 304 const std::string name_; |
| 305 | 305 |
| 306 // Signaled when the created thread gets ready to use the message loop. | 306 // Signaled when the created thread gets ready to use the message loop. |
| 307 mutable WaitableEvent start_event_; | 307 mutable WaitableEvent start_event_; |
| 308 | 308 |
| 309 // This class is not thread-safe, use this to verify access from the owning | 309 // This class is not thread-safe, use this to verify access from the owning |
| 310 // sequence of the Thread. | 310 // sequence of the Thread. |
| 311 SequenceChecker owning_sequence_checker_; | 311 SequenceChecker owning_sequence_checker_; |
| 312 | 312 |
| 313 DISALLOW_COPY_AND_ASSIGN(Thread); | 313 DISALLOW_COPY_AND_ASSIGN(Thread); |
| 314 }; | 314 }; |
| 315 | 315 |
| 316 } // namespace base | 316 } // namespace base |
| 317 | 317 |
| 318 #endif // BASE_THREADING_THREAD_H_ | 318 #endif // BASE_THREADING_THREAD_H_ |
| OLD | NEW |