Home | History | Annotate | Download | only in threading
      1 // Copyright 2015 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 #ifndef BASE_THREADING_PLATFORM_THREAD_INTERNAL_POSIX_H_
      6 #define BASE_THREADING_PLATFORM_THREAD_INTERNAL_POSIX_H_
      7 
      8 #include "base/base_export.h"
      9 #include "base/threading/platform_thread.h"
     10 
     11 namespace base {
     12 
     13 namespace internal {
     14 
     15 struct ThreadPriorityToNiceValuePair {
     16   ThreadPriority priority;
     17   int nice_value;
     18 };
     19 // The elements must be listed in the order of increasing priority (lowest
     20 // priority first), that is, in the order of decreasing nice values (highest
     21 // nice value first).
     22 BASE_EXPORT extern
     23 const ThreadPriorityToNiceValuePair kThreadPriorityToNiceValueMap[4];
     24 
     25 // Returns the nice value matching |priority| based on the platform-specific
     26 // implementation of kThreadPriorityToNiceValueMap.
     27 int ThreadPriorityToNiceValue(ThreadPriority priority);
     28 
     29 // Returns the ThreadPrioirty matching |nice_value| based on the platform-
     30 // specific implementation of kThreadPriorityToNiceValueMap.
     31 BASE_EXPORT ThreadPriority NiceValueToThreadPriority(int nice_value);
     32 
     33 // Allows platform specific tweaks to the generic POSIX solution for
     34 // SetCurrentThreadPriority. Returns true if the platform-specific
     35 // implementation handled this |priority| change, false if the generic
     36 // implementation should instead proceed.
     37 bool SetCurrentThreadPriorityForPlatform(ThreadPriority priority);
     38 
     39 // Returns true if there is a platform-specific ThreadPriority set on the
     40 // current thread (and returns the actual ThreadPriority via |priority|).
     41 // Returns false otherwise, leaving |priority| untouched.
     42 bool GetCurrentThreadPriorityForPlatform(ThreadPriority* priority);
     43 
     44 }  // namespace internal
     45 
     46 }  // namespace base
     47 
     48 #endif  // BASE_THREADING_PLATFORM_THREAD_INTERNAL_POSIX_H_
     49