Inline ConvertToSystemPriority.
Unused function when building Chromium, triggered build errors when
importing webrtc.
BUG=
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/1471073005 .
Cr-Commit-Position: refs/heads/master@{#10768}
diff --git a/webrtc/base/platform_thread.cc b/webrtc/base/platform_thread.cc
index d32311b..02ec3af 100644
--- a/webrtc/base/platform_thread.cc
+++ b/webrtc/base/platform_thread.cc
@@ -100,31 +100,6 @@
pthread_attr_t* operator&() { return &attr; }
pthread_attr_t attr;
};
-
-int ConvertToSystemPriority(ThreadPriority priority,
- int min_prio,
- int max_prio) {
- RTC_DCHECK(max_prio - min_prio > 2);
- const int top_prio = max_prio - 1;
- const int low_prio = min_prio + 1;
-
- switch (priority) {
- case kLowPriority:
- return low_prio;
- case kNormalPriority:
- // The -1 ensures that the kHighPriority is always greater or equal to
- // kNormalPriority.
- return (low_prio + top_prio - 1) / 2;
- case kHighPriority:
- return std::max(top_prio - 2, low_prio);
- case kHighestPriority:
- return std::max(top_prio - 1, low_prio);
- case kRealtimePriority:
- return top_prio;
- }
- RTC_DCHECK(false);
- return low_prio;
-}
#endif // defined(WEBRTC_WIN)
}
@@ -251,13 +226,30 @@
if (max_prio - min_prio <= 2)
return false;
+ // Convert webrtc priority to system priorities:
sched_param param;
- param.sched_priority = ConvertToSystemPriority(priority, min_prio, max_prio);
- if (pthread_setschedparam(thread_, policy, ¶m) != 0) {
- return false;
+ const int top_prio = max_prio - 1;
+ const int low_prio = min_prio + 1;
+ switch (priority) {
+ case kLowPriority:
+ param.sched_priority = low_prio;
+ break;
+ case kNormalPriority:
+ // The -1 ensures that the kHighPriority is always greater or equal to
+ // kNormalPriority.
+ param.sched_priority = (low_prio + top_prio - 1) / 2;
+ break;
+ case kHighPriority:
+ param.sched_priority = std::max(top_prio - 2, low_prio);
+ break;
+ case kHighestPriority:
+ param.sched_priority = std::max(top_prio - 1, low_prio);
+ break;
+ case kRealtimePriority:
+ param.sched_priority = top_prio;
+ break;
}
-
- return true;
+ return pthread_setschedparam(thread_, policy, ¶m) == 0;
#endif // defined(WEBRTC_CHROMIUM_BUILD) && defined(WEBRTC_LINUX)
#endif // defined(WEBRTC_WIN)
}