Index: base/threading/simple_thread.h |
diff --git a/base/threading/simple_thread.h b/base/threading/simple_thread.h |
index f9f5e9104595cff04d97730fc17860a971edd0a4..3efce1636a1a813d39e5c61bab874edf4de30c09 100644 |
--- a/base/threading/simple_thread.h |
+++ b/base/threading/simple_thread.h |
@@ -30,9 +30,8 @@ |
// MyThreadRunner runner; |
// DelegateSimpleThread thread(&runner, "good_name_here"); |
// thread.Start(); |
-// // Start will return after the Thread has been successfully started and |
-// // initialized. The newly created thread will invoke runner->Run(), and |
-// // run until it returns. |
+// // The newly created thread will invoke runner->Run(), and run until it |
+// // returns. |
// thread.Join(); // Wait until the thread has exited. You *MUST* Join! |
// // The SimpleThread object is still valid, however you may not call Join |
// // or Start again. |
@@ -48,6 +47,7 @@ |
#include "base/base_export.h" |
#include "base/compiler_specific.h" |
+#include "base/logging.h" |
#include "base/macros.h" |
#include "base/synchronization/lock.h" |
#include "base/synchronization/waitable_event.h" |
@@ -96,14 +96,8 @@ class BASE_EXPORT SimpleThread : public PlatformThread::Delegate { |
// Subclasses should override the Run method. |
virtual void Run() = 0; |
- // Return the thread id, only valid after Start(). |
- PlatformThreadId tid() { return tid_; } |
- |
- // Return True if Start() has ever been called. |
- bool HasBeenStarted(); |
- |
- // Return True if Join() has ever been called. |
- bool HasBeenJoined() { return joined_; } |
+ // Return the thread id. |
+ PlatformThreadId GetTid() const; |
// Overridden from PlatformThread::Delegate: |
void ThreadMain() override; |
@@ -112,10 +106,20 @@ class BASE_EXPORT SimpleThread : public PlatformThread::Delegate { |
const std::string name_prefix_; |
std::string name_; |
const Options options_; |
- PlatformThreadHandle thread_; // PlatformThread handle, reset after Join. |
- WaitableEvent event_; // Signaled if Start() was ever called. |
- PlatformThreadId tid_ = kInvalidThreadId; // The backing thread's id. |
- bool joined_ = false; // True if Join has been called. |
+ |
+ // PlatformThread handle, reset after Join. |
+ PlatformThreadHandle thread_; |
+ |
+ // Signaled once |tid_| is set. |
+ mutable WaitableEvent id_event_; |
+ |
+ // The backing thread's id. |
+ PlatformThreadId tid_ = kInvalidThreadId; |
+ |
+#if DCHECK_IS_ON() |
+ bool has_been_started_ = false; |
+ bool has_been_joined_ = false; |
+#endif |
DISALLOW_COPY_AND_ASSIGN(SimpleThread); |
}; |