summaryrefslogtreecommitdiffstats
path: root/base/threading
diff options
context:
space:
mode:
authordalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-29 00:50:52 +0000
committerdalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-29 00:50:52 +0000
commit05224701248ca4a3f5a4f48fa19f6206c3edaf6f (patch)
tree65e87a70d7919b6f0085038f2ed31caa54ae46e7 /base/threading
parent72232b1cd627b4ba045504d22413e3d9667eab7f (diff)
downloadchromium_src-05224701248ca4a3f5a4f48fa19f6206c3edaf6f.zip
chromium_src-05224701248ca4a3f5a4f48fa19f6206c3edaf6f.tar.gz
chromium_src-05224701248ca4a3f5a4f48fa19f6206c3edaf6f.tar.bz2
Remove spammy setpriority() failure message. Stylize.
BUG=277834 TEST=compiles Review URL: https://chromiumcodereview.appspot.com/23481008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/threading')
-rw-r--r--base/threading/platform_thread_linux.cc44
1 files changed, 17 insertions, 27 deletions
diff --git a/base/threading/platform_thread_linux.cc b/base/threading/platform_thread_linux.cc
index 80227c3..6d46de4 100644
--- a/base/threading/platform_thread_linux.cc
+++ b/base/threading/platform_thread_linux.cc
@@ -27,19 +27,15 @@ namespace base {
namespace {
int ThreadNiceValue(ThreadPriority priority) {
- static const int threadPriorityAudio = -10;
- static const int threadPriorityBackground = 10;
- static const int threadPriorityDefault = 0;
- static const int threadPriorityDisplay = -6;
switch (priority) {
case kThreadPriority_RealtimeAudio:
- return threadPriorityAudio;
+ return -10;
case kThreadPriority_Background:
- return threadPriorityBackground;
+ return 10;
case kThreadPriority_Normal:
- return threadPriorityDefault;
+ return 0;
case kThreadPriority_Display:
- return threadPriorityDisplay;
+ return -6;
default:
NOTREACHED() << "Unknown priority.";
return 0;
@@ -52,7 +48,7 @@ void PlatformThread::SetName(const char* name) {
ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name);
tracked_objects::ThreadData::InitializeThreadContext(name);
-#ifndef OS_NACL
+#if !defined(OS_NACL)
// On linux we can get the thread names to show up in the debugger by setting
// the process name for the LWP. We don't want to do this for the main
// thread because that would rename the process, causing tools like killall
@@ -69,7 +65,7 @@ void PlatformThread::SetName(const char* name) {
// We expect EPERM failures in sandboxed processes, just ignore those.
if (err < 0 && errno != EPERM)
DPLOG(ERROR) << "prctl(PR_SET_NAME)";
-#endif
+#endif // !defined(OS_NACL)
}
// static
@@ -77,13 +73,8 @@ void PlatformThread::SetThreadPriority(PlatformThreadHandle handle,
ThreadPriority priority) {
#if !defined(OS_NACL)
if (priority == kThreadPriority_RealtimeAudio) {
- const int kRealTimePrio = 8;
-
- struct sched_param sched_param;
- memset(&sched_param, 0, sizeof(sched_param));
- sched_param.sched_priority = kRealTimePrio;
-
- if (pthread_setschedparam(pthread_self(), SCHED_RR, &sched_param) == 0) {
+ const struct sched_param kRealTimePrio = { 8 };
+ if (pthread_setschedparam(pthread_self(), SCHED_RR, &kRealTimePrio) == 0) {
// Got real time priority, no need to set nice level.
return;
}
@@ -94,20 +85,19 @@ void PlatformThread::SetThreadPriority(PlatformThreadHandle handle,
// process. Setting this priority will only succeed if the user has been
// granted permission to adjust nice values on the system.
DCHECK_NE(handle.id_, kInvalidThreadId);
- int kNiceSetting = ThreadNiceValue(priority);
- if (setpriority(PRIO_PROCESS, handle.id_, kNiceSetting))
- LOG(ERROR) << "Failed to set nice value of thread to " << kNiceSetting;
-#endif // !OS_NACL
+ const int kNiceSetting = ThreadNiceValue(priority);
+ if (setpriority(PRIO_PROCESS, handle.id_, kNiceSetting)) {
+ DVPLOG(1) << "Failed to set nice value of thread ("
+ << handle.id_ << ") to " << kNiceSetting;
+ }
+#endif // !defined(OS_NACL)
}
-void InitThreading() {
-}
+void InitThreading() {}
-void InitOnThread() {
-}
+void InitOnThread() {}
-void TerminateOnThread() {
-}
+void TerminateOnThread() {}
size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) {
return 0;