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

Unified Diff: base/threading/platform_thread_freebsd.cc

Issue 1006933003: Add full SetThreadPriority support to Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test exit race Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: base/threading/platform_thread_freebsd.cc
diff --git a/base/threading/platform_thread_freebsd.cc b/base/threading/platform_thread_freebsd.cc
index a163f650443d08f1602ff295e8c985dab7c7ddd2..ee523db8db0c33599397dc98c859e6c939420d29 100644
--- a/base/threading/platform_thread_freebsd.cc
+++ b/base/threading/platform_thread_freebsd.cc
@@ -36,8 +36,8 @@ const ThreadPriorityToNiceValuePair kThreadPriorityToNiceValueMap[4] = {
{ kThreadPriority_Display, -6 },
}
-bool HandleSetThreadPriorityForPlatform(PlatformThreadHandle handle,
- ThreadPriority priority) {
+bool SetThreadPriorityForPlatform(PlatformThreadHandle handle,
+ ThreadPriority priority) {
#if !defined(OS_NACL)
return priority == kThreadPriority_RealtimeAudio &&
pthread_setschedparam(pthread_self(), SCHED_RR, &kRealTimePrio) == 0;
@@ -46,6 +46,23 @@ bool HandleSetThreadPriorityForPlatform(PlatformThreadHandle handle,
#endif
}
+bool GetThreadPriorityForPlatform(PlatformThreadHandle handle,
+ ThreadPriority* priority) {
+#if !defined(OS_NACL)
+ // Mirrors SetThreadPriorityForPlatform()'s implementation.
+ int maybe_sched_rr = 0;
+ struct sched_param maybe_realtime_prio = {0};
+ if (pthread_getschedparam(pthread_self(), &maybe_sched_rr,
rvargas (doing something else) 2015/03/31 19:27:10 Don't see the TODO
gab 2015/03/31 20:18:20 Oops had put it in _linux.cc only...
+ &maybe_realtime_prio) == 0 &&
+ maybe_sched_rr == SCHED_RR &&
+ maybe_realtime_prio.sched_priority == kRealTimePrio.sched_priority) {
+ *priority = kThreadPriority_RealtimeAudio;
+ return true;
+ }
+#endif
+ return false;
+}
+
} // namespace internal
// static

Powered by Google App Engine
This is Rietveld 408576698