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 // WARNING: You should *NOT* be using this class directly. PlatformThread is | 5 // WARNING: You should *NOT* be using this class directly. PlatformThread is |
6 // the low-level platform-specific abstraction to the OS's threading interface. | 6 // the low-level platform-specific abstraction to the OS's threading interface. |
7 // You should instead be using a message-loop driven Thread, see thread.h. | 7 // You should instead be using a message-loop driven Thread, see thread.h. |
8 | 8 |
9 #ifndef BASE_THREADING_PLATFORM_THREAD_H_ | 9 #ifndef BASE_THREADING_PLATFORM_THREAD_H_ |
10 #define BASE_THREADING_PLATFORM_THREAD_H_ | 10 #define BASE_THREADING_PLATFORM_THREAD_H_ |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // to raise its priority back up after lowering it if the process does not | 198 // to raise its priority back up after lowering it if the process does not |
199 // have a proper permission, e.g. CAP_SYS_NICE on Linux. A thread may not be | 199 // have a proper permission, e.g. CAP_SYS_NICE on Linux. A thread may not be |
200 // able to lower its priority back down after raising it to REALTIME_AUDIO. | 200 // able to lower its priority back down after raising it to REALTIME_AUDIO. |
201 // Since changing other threads' priority is not permitted in favor of | 201 // Since changing other threads' priority is not permitted in favor of |
202 // security, this interface is restricted to change only the current thread | 202 // security, this interface is restricted to change only the current thread |
203 // priority (https://crbug.com/399473). | 203 // priority (https://crbug.com/399473). |
204 static void SetCurrentThreadPriority(ThreadPriority priority); | 204 static void SetCurrentThreadPriority(ThreadPriority priority); |
205 | 205 |
206 static ThreadPriority GetCurrentThreadPriority(); | 206 static ThreadPriority GetCurrentThreadPriority(); |
207 | 207 |
| 208 #if defined(OS_LINUX) |
| 209 // Toggles a specific thread's priority at runtime. This can be used to |
| 210 // change the priority of a thread in a different process and will fail |
| 211 // if the calling process does not have proper permissions. The |
| 212 // SetCurrentThreadPriority() function above is preferred in favor of |
| 213 // security but on platforms where sandboxed processes are not allowed to |
| 214 // change priority this function exists to allow a non-sandboxed process |
| 215 // to change the priority of sandboxed threads for improved performance. |
| 216 // Warning: Don't use this for a main thread because that will change the |
| 217 // whole thread group's (i.e. process) priority. |
| 218 static void SetThreadPriority(PlatformThreadId thread_id, |
| 219 ThreadPriority priority); |
| 220 #endif |
| 221 |
208 private: | 222 private: |
209 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); | 223 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); |
210 }; | 224 }; |
211 | 225 |
212 } // namespace base | 226 } // namespace base |
213 | 227 |
214 #endif // BASE_THREADING_PLATFORM_THREAD_H_ | 228 #endif // BASE_THREADING_PLATFORM_THREAD_H_ |
OLD | NEW |