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

Side by Side Diff: base/threading/platform_thread_mac.mm

Issue 12741012: base: Support setting thread priorities generically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added back JNI for Audio. Created 7 years, 8 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 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #include <dlfcn.h> 8 #include <dlfcn.h>
9 #include <mach/mach.h> 9 #include <mach/mach.h>
10 #include <mach/mach_time.h> 10 #include <mach/mach_time.h>
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 if (result != KERN_SUCCESS) 154 if (result != KERN_SUCCESS)
155 DVLOG(1) << "thread_policy_set() failure: " << result; 155 DVLOG(1) << "thread_policy_set() failure: " << result;
156 156
157 return; 157 return;
158 } 158 }
159 159
160 } // anonymous namespace 160 } // anonymous namespace
161 161
162 // static 162 // static
163 void PlatformThread::SetThreadPriority(PlatformThreadHandle handle, 163 void PlatformThread::SetThreadPriority(PlatformThreadHandle handle,
164 PlatformThreadId,
164 ThreadPriority priority) { 165 ThreadPriority priority) {
165 // Convert from pthread_t to mach thread identifier. 166 // Convert from pthread_t to mach thread identifier.
166 mach_port_t mach_thread_id = pthread_mach_thread_np(handle); 167 mach_port_t mach_thread_id = pthread_mach_thread_np(handle);
167 168
168 switch (priority) { 169 switch (priority) {
169 case kThreadPriority_Normal: 170 case kThreadPriority_Normal:
170 SetPriorityNormal(mach_thread_id); 171 SetPriorityNormal(mach_thread_id);
171 break; 172 break;
172 case kThreadPriority_RealtimeAudio: 173 case kThreadPriority_RealtimeAudio:
173 SetPriorityRealtimeAudio(mach_thread_id); 174 SetPriorityRealtimeAudio(mach_thread_id);
174 break; 175 break;
176 default:
177 NOTREACHED() << "Unknown priority.";
178 break;
175 } 179 }
176 } 180 }
177 181
178 } // namespace base 182 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698