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 #include "base/threading/thread.h" | 5 #include "base/threading/thread.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 thread_id_ = PlatformThread::CurrentId(); | 154 thread_id_ = PlatformThread::CurrentId(); |
155 PlatformThread::SetName(name_.c_str()); | 155 PlatformThread::SetName(name_.c_str()); |
156 ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. | 156 ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. |
157 message_loop.set_thread_name(name_); | 157 message_loop.set_thread_name(name_); |
158 message_loop_ = &message_loop; | 158 message_loop_ = &message_loop; |
159 | 159 |
160 // Let the thread do extra initialization. | 160 // Let the thread do extra initialization. |
161 // Let's do this before signaling we are started. | 161 // Let's do this before signaling we are started. |
162 Init(); | 162 Init(); |
163 | 163 |
| 164 running_ = true; |
164 startup_data_->event.Signal(); | 165 startup_data_->event.Signal(); |
165 // startup_data_ can't be touched anymore since the starting thread is now | 166 // startup_data_ can't be touched anymore since the starting thread is now |
166 // unlocked. | 167 // unlocked. |
167 | 168 |
168 running_ = true; | |
169 Run(message_loop_); | 169 Run(message_loop_); |
170 running_ = false; | 170 running_ = false; |
171 | 171 |
172 // Let the thread do extra cleanup. | 172 // Let the thread do extra cleanup. |
173 CleanUp(); | 173 CleanUp(); |
174 | 174 |
175 // Assert that MessageLoop::Quit was called by ThreadQuitHelper. | 175 // Assert that MessageLoop::Quit was called by ThreadQuitHelper. |
176 DCHECK(GetThreadWasQuitProperly()); | 176 DCHECK(GetThreadWasQuitProperly()); |
177 | 177 |
178 // We can't receive messages anymore. | 178 // We can't receive messages anymore. |
179 message_loop_ = NULL; | 179 message_loop_ = NULL; |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 } // namespace base | 183 } // namespace base |
OLD | NEW |