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

Side by Side Diff: base/threading/thread.h

Issue 10399097: Base: Don't overwrite the thread id when ThreadMain exits. There's (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/threading/thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_THREAD_H_ 5 #ifndef BASE_THREAD_H_
6 #define BASE_THREAD_H_ 6 #define BASE_THREAD_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // Returns the name of this thread (for display in debugger too). 124 // Returns the name of this thread (for display in debugger too).
125 const std::string &thread_name() { return name_; } 125 const std::string &thread_name() { return name_; }
126 126
127 // The native thread handle. 127 // The native thread handle.
128 PlatformThreadHandle thread_handle() { return thread_; } 128 PlatformThreadHandle thread_handle() { return thread_; }
129 129
130 // The thread ID. 130 // The thread ID.
131 PlatformThreadId thread_id() const { return thread_id_; } 131 PlatformThreadId thread_id() const { return thread_id_; }
132 132
133 // Returns true if the thread has been started, and not yet stopped. 133 // Returns true if the thread has been started, and not yet stopped.
134 // When a thread is running, |thread_id_| is a valid id. 134 bool IsRunning() const;
135 bool IsRunning() const { return thread_id_ != kInvalidThreadId; }
136 135
137 protected: 136 protected:
138 // Called just prior to starting the message loop 137 // Called just prior to starting the message loop
139 virtual void Init() {} 138 virtual void Init() {}
140 139
141 // Called to start the message loop 140 // Called to start the message loop
142 virtual void Run(MessageLoop* message_loop); 141 virtual void Run(MessageLoop* message_loop);
143 142
144 // Called just after the message loop ends 143 // Called just after the message loop ends
145 virtual void CleanUp() {} 144 virtual void CleanUp() {}
(...skipping 11 matching lines...) Expand all
157 // PlatformThread::Delegate methods: 156 // PlatformThread::Delegate methods:
158 virtual void ThreadMain() OVERRIDE; 157 virtual void ThreadMain() OVERRIDE;
159 158
160 // Whether we successfully started the thread. 159 // Whether we successfully started the thread.
161 bool started_; 160 bool started_;
162 161
163 // If true, we're in the middle of stopping, and shouldn't access 162 // If true, we're in the middle of stopping, and shouldn't access
164 // |message_loop_|. It may non-NULL and invalid. 163 // |message_loop_|. It may non-NULL and invalid.
165 bool stopping_; 164 bool stopping_;
166 165
166 // True while inside of Run().
167 bool running_;
168
167 // Used to pass data to ThreadMain. 169 // Used to pass data to ThreadMain.
168 struct StartupData; 170 struct StartupData;
169 StartupData* startup_data_; 171 StartupData* startup_data_;
170 172
171 // The thread's handle. 173 // The thread's handle.
172 PlatformThreadHandle thread_; 174 PlatformThreadHandle thread_;
173 175
174 // The thread's message loop. Valid only while the thread is alive. Set 176 // The thread's message loop. Valid only while the thread is alive. Set
175 // by the created thread. 177 // by the created thread.
176 MessageLoop* message_loop_; 178 MessageLoop* message_loop_;
177 179
178 // Our thread's ID. 180 // Our thread's ID.
179 PlatformThreadId thread_id_; 181 PlatformThreadId thread_id_;
180 182
181 // The name of the thread. Used for debugging purposes. 183 // The name of the thread. Used for debugging purposes.
182 std::string name_; 184 std::string name_;
183 185
184 friend void ThreadQuitHelper(); 186 friend void ThreadQuitHelper();
185 187
186 DISALLOW_COPY_AND_ASSIGN(Thread); 188 DISALLOW_COPY_AND_ASSIGN(Thread);
187 }; 189 };
188 190
189 } // namespace base 191 } // namespace base
190 192
191 #endif // BASE_THREAD_H_ 193 #endif // BASE_THREAD_H_
OLDNEW
« no previous file with comments | « no previous file | base/threading/thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698