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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // the thread is set based on |priority|. | 168 // the thread is set based on |priority|. |
169 static bool CreateWithPriority(size_t stack_size, Delegate* delegate, | 169 static bool CreateWithPriority(size_t stack_size, Delegate* delegate, |
170 PlatformThreadHandle* thread_handle, | 170 PlatformThreadHandle* thread_handle, |
171 ThreadPriority priority); | 171 ThreadPriority priority); |
172 | 172 |
173 // CreateNonJoinable() does the same thing as Create() except the thread | 173 // CreateNonJoinable() does the same thing as Create() except the thread |
174 // cannot be Join()'d. Therefore, it also does not output a | 174 // cannot be Join()'d. Therefore, it also does not output a |
175 // PlatformThreadHandle. | 175 // PlatformThreadHandle. |
176 static bool CreateNonJoinable(size_t stack_size, Delegate* delegate); | 176 static bool CreateNonJoinable(size_t stack_size, Delegate* delegate); |
177 | 177 |
| 178 // CreateNonJoinableWithPriority() does the same thing as CreateNonJoinable() |
| 179 // except the priority of the thread is set based on |priority|. |
| 180 static bool CreateNonJoinableWithPriority(size_t stack_size, |
| 181 Delegate* delegate, |
| 182 ThreadPriority priority); |
| 183 |
178 // Joins with a thread created via the Create function. This function blocks | 184 // Joins with a thread created via the Create function. This function blocks |
179 // the caller until the designated thread exits. This will invalidate | 185 // the caller until the designated thread exits. This will invalidate |
180 // |thread_handle|. | 186 // |thread_handle|. |
181 static void Join(PlatformThreadHandle thread_handle); | 187 static void Join(PlatformThreadHandle thread_handle); |
182 | 188 |
183 // Detaches and releases the thread handle. The thread is no longer joinable | 189 // Detaches and releases the thread handle. The thread is no longer joinable |
184 // and |thread_handle| is invalidated after this call. | 190 // and |thread_handle| is invalidated after this call. |
185 static void Detach(PlatformThreadHandle thread_handle); | 191 static void Detach(PlatformThreadHandle thread_handle); |
186 | 192 |
187 // Toggles the current thread's priority at runtime. A thread may not be able | 193 // Toggles the current thread's priority at runtime. A thread may not be able |
188 // to raise its priority back up after lowering it if the process does not | 194 // to raise its priority back up after lowering it if the process does not |
189 // have a proper permission, e.g. CAP_SYS_NICE on Linux. A thread may not be | 195 // have a proper permission, e.g. CAP_SYS_NICE on Linux. A thread may not be |
190 // able to lower its priority back down after raising it to REALTIME_AUDIO. | 196 // able to lower its priority back down after raising it to REALTIME_AUDIO. |
191 // Since changing other threads' priority is not permitted in favor of | 197 // Since changing other threads' priority is not permitted in favor of |
192 // security, this interface is restricted to change only the current thread | 198 // security, this interface is restricted to change only the current thread |
193 // priority (https://crbug.com/399473). | 199 // priority (https://crbug.com/399473). |
194 static void SetCurrentThreadPriority(ThreadPriority priority); | 200 static void SetCurrentThreadPriority(ThreadPriority priority); |
195 | 201 |
196 static ThreadPriority GetCurrentThreadPriority(); | 202 static ThreadPriority GetCurrentThreadPriority(); |
197 | 203 |
198 private: | 204 private: |
199 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); | 205 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); |
200 }; | 206 }; |
201 | 207 |
202 } // namespace base | 208 } // namespace base |
203 | 209 |
204 #endif // BASE_THREADING_PLATFORM_THREAD_H_ | 210 #endif // BASE_THREADING_PLATFORM_THREAD_H_ |
OLD | NEW |