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

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

Issue 12741012: base: Support setting thread priorities generically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove static initializers. Created 7 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
« no previous file with comments | « base/threading/thread.h ('k') | base/threading/thread_restrictions.h » ('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 #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
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
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
OLDNEW
« no previous file with comments | « base/threading/thread.h ('k') | base/threading/thread_restrictions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698