Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3400)

Unified Diff: base/threading/thread.h

Issue 1207823004: PlatformThreadHandle: remove public id() interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: keep thread_id after Stop() Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/threading/thread.h
diff --git a/base/threading/thread.h b/base/threading/thread.h
index 5126491b3861cdb60f23eec1b40b11466d27a33a..f207dc1c1b5c05c30089501551cdb0803fc33413 100644
--- a/base/threading/thread.h
+++ b/base/threading/thread.h
@@ -118,7 +118,7 @@ class BASE_EXPORT Thread : PlatformThread::Delegate {
// Blocks until the thread starts running. Called within StartAndWait().
// Note that calling this causes jank on the calling thread, must be used
// carefully for production code.
- bool WaitUntilThreadStarted();
+ bool WaitUntilThreadStarted() const;
// Signals the thread to exit and returns once the thread has exited. After
// this method returns, the Thread object is completely reset and may be used
@@ -170,7 +170,7 @@ class BASE_EXPORT Thread : PlatformThread::Delegate {
// The native thread handle.
PlatformThreadHandle thread_handle() { return thread_; }
- // The thread ID.
+ // The thread ID. Should be called after one of Start*() is called.
PlatformThreadId thread_id() const;
// Returns true if the thread has been started, and not yet stopped.
@@ -212,15 +212,21 @@ class BASE_EXPORT Thread : PlatformThread::Delegate {
// If true, we're in the middle of stopping, and shouldn't access
// |message_loop_|. It may non-NULL and invalid.
+ // Should be written on the thread that creates this thread. Also read data
+ // could be wrong on other threads.
bool stopping_;
// True while inside of Run().
bool running_;
- mutable base::Lock running_lock_; // Protects running_.
+
+ // Protects |running_|.
+ mutable base::Lock running_lock_;
// The thread's handle.
PlatformThreadHandle thread_;
- mutable base::Lock thread_lock_; // Protects thread_.
+
+ // The thread's id once it was started. Ensured by |start_event_|.
+ PlatformThreadId id_;
// The thread's message loop. Valid only while the thread is alive. Set
// by the created thread.

Powered by Google App Engine
This is Rietveld 408576698