| 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_id_name_manager.h" | 10 #include "base/threading/thread_id_name_manager.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 return; | 141 return; |
| 142 | 142 |
| 143 stopping_ = true; | 143 stopping_ = true; |
| 144 message_loop_->PostTask(FROM_HERE, base::Bind(&ThreadQuitHelper)); | 144 message_loop_->PostTask(FROM_HERE, base::Bind(&ThreadQuitHelper)); |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool Thread::IsRunning() const { | 147 bool Thread::IsRunning() const { |
| 148 return running_; | 148 return running_; |
| 149 } | 149 } |
| 150 | 150 |
| 151 void Thread::SetPriority(ThreadPriority priority) { |
| 152 // The thread must be started (and id known) for this to be |
| 153 // compatible with all platforms. |
| 154 DCHECK_NE(thread_id_, kInvalidThreadId); |
| 155 PlatformThread::SetThreadPriority(thread_, priority); |
| 156 } |
| 157 |
| 151 void Thread::Run(MessageLoop* message_loop) { | 158 void Thread::Run(MessageLoop* message_loop) { |
| 152 message_loop->Run(); | 159 message_loop->Run(); |
| 153 } | 160 } |
| 154 | 161 |
| 155 void Thread::SetThreadWasQuitProperly(bool flag) { | 162 void Thread::SetThreadWasQuitProperly(bool flag) { |
| 156 lazy_tls_bool.Pointer()->Set(flag); | 163 lazy_tls_bool.Pointer()->Set(flag); |
| 157 } | 164 } |
| 158 | 165 |
| 159 bool Thread::GetThreadWasQuitProperly() { | 166 bool Thread::GetThreadWasQuitProperly() { |
| 160 bool quit_properly = true; | 167 bool quit_properly = true; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 213 |
| 207 // Assert that MessageLoop::Quit was called by ThreadQuitHelper. | 214 // Assert that MessageLoop::Quit was called by ThreadQuitHelper. |
| 208 DCHECK(GetThreadWasQuitProperly()); | 215 DCHECK(GetThreadWasQuitProperly()); |
| 209 | 216 |
| 210 // We can't receive messages anymore. | 217 // We can't receive messages anymore. |
| 211 message_loop_ = NULL; | 218 message_loop_ = NULL; |
| 212 } | 219 } |
| 213 } | 220 } |
| 214 | 221 |
| 215 } // namespace base | 222 } // namespace base |
| OLD | NEW |