OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/threading/platform_thread.h" |
| 6 |
| 7 #include <pthread.h> |
| 8 #include <sched.h> |
| 9 |
| 10 #include "base/threading/platform_thread_internal_posix.h" |
| 11 |
| 12 namespace base { |
| 13 |
| 14 namespace internal { |
| 15 |
| 16 const ThreadPriorityToNiceValuePair kThreadPriorityToNiceValueMap[4] = { |
| 17 {ThreadPriority::BACKGROUND, 10}, |
| 18 {ThreadPriority::NORMAL, 0}, |
| 19 {ThreadPriority::DISPLAY, -8}, |
| 20 {ThreadPriority::REALTIME_AUDIO, -10}, |
| 21 }; |
| 22 |
| 23 bool SetCurrentThreadPriorityForPlatform(ThreadPriority priority) { |
| 24 sched_param prio = {0}; |
| 25 prio.sched_priority = ThreadPriorityToNiceValue(priority); |
| 26 return pthread_setschedparam(pthread_self(), SCHED_OTHER, &prio) == 0; |
| 27 } |
| 28 |
| 29 bool GetCurrentThreadPriorityForPlatform(ThreadPriority* priority) { |
| 30 sched_param prio = {0}; |
| 31 int policy; |
| 32 if (pthread_getschedparam(pthread_self(), &policy, &prio) != 0) { |
| 33 return false; |
| 34 } |
| 35 *priority = NiceValueToThreadPriority(prio.sched_priority); |
| 36 return true; |
| 37 } |
| 38 |
| 39 } // namespace internal |
| 40 |
| 41 void InitThreading() {} |
| 42 |
| 43 void TerminateOnThread() {} |
| 44 |
| 45 size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) { |
| 46 return 0; |
| 47 } |
| 48 |
| 49 // static |
| 50 void PlatformThread::SetName(const std::string& name) { |
| 51 // TODO(fuchsia): There's no available API at the moment to set the thread |
| 52 // name. See https://crbug.com/725726. |
| 53 } |
| 54 |
| 55 } // namespace base |
OLD | NEW |