| OLD | NEW |
| 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 <errno.h> | 7 #include <errno.h> |
| 8 #include <pthread.h> | 8 #include <pthread.h> |
| 9 #include <sched.h> | 9 #include <sched.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 PlatformThread::Delegate* delegate = nullptr; | 50 PlatformThread::Delegate* delegate = nullptr; |
| 51 | 51 |
| 52 { | 52 { |
| 53 scoped_ptr<ThreadParams> thread_params(static_cast<ThreadParams*>(params)); | 53 scoped_ptr<ThreadParams> thread_params(static_cast<ThreadParams*>(params)); |
| 54 | 54 |
| 55 delegate = thread_params->delegate; | 55 delegate = thread_params->delegate; |
| 56 if (!thread_params->joinable) | 56 if (!thread_params->joinable) |
| 57 base::ThreadRestrictions::SetSingletonAllowed(false); | 57 base::ThreadRestrictions::SetSingletonAllowed(false); |
| 58 | 58 |
| 59 if (thread_params->priority != ThreadPriority::NORMAL) | 59 // Threads on linux/android may inherit their priority from the thread |
| 60 PlatformThread::SetCurrentThreadPriority(thread_params->priority); | 60 // where they were created. This explicitly sets the priority of all new |
| 61 // threads. |
| 62 PlatformThread::SetCurrentThreadPriority(thread_params->priority); |
| 61 } | 63 } |
| 62 | 64 |
| 63 ThreadIdNameManager::GetInstance()->RegisterThread( | 65 ThreadIdNameManager::GetInstance()->RegisterThread( |
| 64 PlatformThread::CurrentHandle().platform_handle(), | 66 PlatformThread::CurrentHandle().platform_handle(), |
| 65 PlatformThread::CurrentId()); | 67 PlatformThread::CurrentId()); |
| 66 | 68 |
| 67 delegate->ThreadMain(); | 69 delegate->ThreadMain(); |
| 68 | 70 |
| 69 ThreadIdNameManager::GetInstance()->RemoveName( | 71 ThreadIdNameManager::GetInstance()->RemoveName( |
| 70 PlatformThread::CurrentHandle().platform_handle(), | 72 PlatformThread::CurrentHandle().platform_handle(), |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 return ThreadPriority::NORMAL; | 256 return ThreadPriority::NORMAL; |
| 255 } | 257 } |
| 256 | 258 |
| 257 return internal::NiceValueToThreadPriority(nice_value); | 259 return internal::NiceValueToThreadPriority(nice_value); |
| 258 #endif // !defined(OS_NACL) | 260 #endif // !defined(OS_NACL) |
| 259 } | 261 } |
| 260 | 262 |
| 261 #endif // !defined(OS_MACOSX) | 263 #endif // !defined(OS_MACOSX) |
| 262 | 264 |
| 263 } // namespace base | 265 } // namespace base |
| OLD | NEW |