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

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

Issue 12741012: base: Support setting thread priorities generically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. 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
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/platform_thread.h" 5 #include "base/threading/platform_thread.h"
6 6
7 #include "base/debug/alias.h" 7 #include "base/debug/alias.h"
8 #include "base/debug/profiler.h" 8 #include "base/debug/profiler.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/threading/thread_id_name_manager.h" 10 #include "base/threading/thread_id_name_manager.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 DCHECK(thread_handle); 146 DCHECK(thread_handle);
147 return CreateThreadInternal(stack_size, delegate, thread_handle); 147 return CreateThreadInternal(stack_size, delegate, thread_handle);
148 } 148 }
149 149
150 // static 150 // static
151 bool PlatformThread::CreateWithPriority(size_t stack_size, Delegate* delegate, 151 bool PlatformThread::CreateWithPriority(size_t stack_size, Delegate* delegate,
152 PlatformThreadHandle* thread_handle, 152 PlatformThreadHandle* thread_handle,
153 ThreadPriority priority) { 153 ThreadPriority priority) {
154 bool result = Create(stack_size, delegate, thread_handle); 154 bool result = Create(stack_size, delegate, thread_handle);
155 if (result) 155 if (result)
156 SetThreadPriority(*thread_handle, priority); 156 SetThreadPriority(*thread_handle, 0, priority);
157 return result; 157 return result;
158 } 158 }
159 159
160 // static 160 // static
161 bool PlatformThread::CreateNonJoinable(size_t stack_size, Delegate* delegate) { 161 bool PlatformThread::CreateNonJoinable(size_t stack_size, Delegate* delegate) {
162 return CreateThreadInternal(stack_size, delegate, NULL); 162 return CreateThreadInternal(stack_size, delegate, NULL);
163 } 163 }
164 164
165 // static 165 // static
166 void PlatformThread::Join(PlatformThreadHandle thread_handle) { 166 void PlatformThread::Join(PlatformThreadHandle thread_handle) {
(...skipping 17 matching lines...) Expand all
184 debug::Alias(&result); 184 debug::Alias(&result);
185 debug::Alias(&thread_handle); 185 debug::Alias(&thread_handle);
186 CHECK(false); 186 CHECK(false);
187 } 187 }
188 188
189 CloseHandle(thread_handle); 189 CloseHandle(thread_handle);
190 } 190 }
191 191
192 // static 192 // static
193 void PlatformThread::SetThreadPriority(PlatformThreadHandle handle, 193 void PlatformThread::SetThreadPriority(PlatformThreadHandle handle,
194 PlatformThreadId,
194 ThreadPriority priority) { 195 ThreadPriority priority) {
195 switch (priority) { 196 switch (priority) {
196 case kThreadPriority_Normal: 197 case kThreadPriority_Normal:
197 ::SetThreadPriority(handle, THREAD_PRIORITY_NORMAL); 198 ::SetThreadPriority(handle, THREAD_PRIORITY_NORMAL);
198 break; 199 break;
199 case kThreadPriority_RealtimeAudio: 200 case kThreadPriority_RealtimeAudio:
200 ::SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); 201 ::SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL);
201 break; 202 break;
203 default:
204 NOTREACHED() << "Unknown priority.";
205 break;
202 } 206 }
203 } 207 }
204 208
205 } // namespace base 209 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698