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

Side by Side 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: review #14, #16 (upstream 1193303002 for review) 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 unified diff | Download patch
OLDNEW
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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 scoped_refptr<SingleThreadTaskRunner> task_runner() const { 163 scoped_refptr<SingleThreadTaskRunner> task_runner() const {
164 return message_loop_ ? message_loop_->task_runner() : nullptr; 164 return message_loop_ ? message_loop_->task_runner() : nullptr;
165 } 165 }
166 166
167 // Returns the name of this thread (for display in debugger too). 167 // Returns the name of this thread (for display in debugger too).
168 const std::string& thread_name() const { return name_; } 168 const std::string& thread_name() const { return name_; }
169 169
170 // The native thread handle. 170 // The native thread handle.
171 PlatformThreadHandle thread_handle() { return thread_; } 171 PlatformThreadHandle thread_handle() { return thread_; }
172 172
173 // The thread ID. 173 // The thread ID. Only valid after this Thread was started.
174 PlatformThreadId thread_id() const; 174 PlatformThreadId thread_id() const;
175 175
176 // Returns true if the thread has been started, and not yet stopped. 176 // Returns true if the thread has been started, and not yet stopped.
177 bool IsRunning() const; 177 bool IsRunning() const;
178 178
179 protected: 179 protected:
180 // Called just prior to starting the message loop 180 // Called just prior to starting the message loop
181 virtual void Init() {} 181 virtual void Init() {}
182 182
183 // Called to start the message loop 183 // Called to start the message loop
(...skipping 25 matching lines...) Expand all
209 // Whether this thread needs to initialize COM, and if so, in what mode. 209 // Whether this thread needs to initialize COM, and if so, in what mode.
210 ComStatus com_status_; 210 ComStatus com_status_;
211 #endif 211 #endif
212 212
213 // If true, we're in the middle of stopping, and shouldn't access 213 // If true, we're in the middle of stopping, and shouldn't access
214 // |message_loop_|. It may non-NULL and invalid. 214 // |message_loop_|. It may non-NULL and invalid.
215 bool stopping_; 215 bool stopping_;
216 216
217 // True while inside of Run(). 217 // True while inside of Run().
218 bool running_; 218 bool running_;
219 mutable base::Lock running_lock_; // Protects running_. 219 mutable base::Lock running_lock_; // Protects |running_|.
220 220
221 // The thread's handle. 221 // The thread's handle.
222 PlatformThreadHandle thread_; 222 PlatformThreadHandle thread_;
223 mutable base::Lock thread_lock_; // Protects thread_. 223 mutable base::Lock thread_lock_; // Protects |thread_|.
224
225 // The thread's id once it was started.
226 PlatformThreadId id_;
227 mutable base::Lock id_lock_; // Protects |id_|.
gab 2015/07/09 18:19:00 I'm not convinced there is enough contention to ju
Takashi Toyoshima 2015/07/14 10:47:28 Done.
gab 2015/07/16 17:28:24 To be clear, I didn't mean to say lock-less, just
224 228
225 // The thread's message loop. Valid only while the thread is alive. Set 229 // The thread's message loop. Valid only while the thread is alive. Set
226 // by the created thread. 230 // by the created thread.
227 MessageLoop* message_loop_; 231 MessageLoop* message_loop_;
228 232
229 // Stores Options::timer_slack_ until the message loop has been bound to 233 // Stores Options::timer_slack_ until the message loop has been bound to
230 // a thread. 234 // a thread.
231 TimerSlack message_loop_timer_slack_; 235 TimerSlack message_loop_timer_slack_;
232 236
233 // The name of the thread. Used for debugging purposes. 237 // The name of the thread. Used for debugging purposes.
234 std::string name_; 238 std::string name_;
235 239
236 // Non-null if the thread has successfully started. 240 // Non-null if the thread has successfully started.
237 scoped_ptr<WaitableEvent> start_event_; 241 scoped_ptr<WaitableEvent> start_event_;
238 242
239 friend void ThreadQuitHelper(); 243 friend void ThreadQuitHelper();
240 244
241 DISALLOW_COPY_AND_ASSIGN(Thread); 245 DISALLOW_COPY_AND_ASSIGN(Thread);
242 }; 246 };
243 247
244 } // namespace base 248 } // namespace base
245 249
246 #endif // BASE_THREADING_THREAD_H_ 250 #endif // BASE_THREADING_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698