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 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 #include <mach/mach.h> | 8 #include <mach/mach.h> |
9 #include <mach/mach_time.h> | 9 #include <mach/mach_time.h> |
10 #include <mach/thread_policy.h> | 10 #include <mach/thread_policy.h> |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 reinterpret_cast<thread_policy_t>(&time_constraints), | 148 reinterpret_cast<thread_policy_t>(&time_constraints), |
149 THREAD_TIME_CONSTRAINT_POLICY_COUNT); | 149 THREAD_TIME_CONSTRAINT_POLICY_COUNT); |
150 MACH_DVLOG_IF(1, result != KERN_SUCCESS, result) << "thread_policy_set"; | 150 MACH_DVLOG_IF(1, result != KERN_SUCCESS, result) << "thread_policy_set"; |
151 | 151 |
152 return; | 152 return; |
153 } | 153 } |
154 | 154 |
155 } // anonymous namespace | 155 } // anonymous namespace |
156 | 156 |
157 // static | 157 // static |
158 void PlatformThread::SetThreadPriority(PlatformThreadHandle handle, | 158 void PlatformThread::SetCurrentThreadPriority(ThreadPriority priority) { |
159 ThreadPriority priority) { | |
160 // Convert from pthread_t to mach thread identifier. | 159 // Convert from pthread_t to mach thread identifier. |
161 mach_port_t mach_thread_id = pthread_mach_thread_np(handle.platform_handle()); | 160 mach_port_t mach_thread_id = |
| 161 pthread_mach_thread_np(PlatformThread::CurrentHandle().platform_handle()); |
162 | 162 |
163 switch (priority) { | 163 switch (priority) { |
164 case ThreadPriority::NORMAL: | 164 case ThreadPriority::NORMAL: |
165 SetPriorityNormal(mach_thread_id); | 165 SetPriorityNormal(mach_thread_id); |
166 break; | 166 break; |
167 case ThreadPriority::REALTIME_AUDIO: | 167 case ThreadPriority::REALTIME_AUDIO: |
168 SetPriorityRealtimeAudio(mach_thread_id); | 168 SetPriorityRealtimeAudio(mach_thread_id); |
169 break; | 169 break; |
170 default: | 170 default: |
171 NOTREACHED() << "Unknown priority."; | 171 NOTREACHED() << "Unknown priority."; |
172 break; | 172 break; |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 // static | 176 // static |
177 ThreadPriority PlatformThread::GetThreadPriority(PlatformThreadHandle handle) { | 177 ThreadPriority PlatformThread::GetCurrentThreadPriority() { |
178 NOTIMPLEMENTED(); | 178 NOTIMPLEMENTED(); |
179 return ThreadPriority::NORMAL; | 179 return ThreadPriority::NORMAL; |
180 } | 180 } |
181 | 181 |
182 size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) { | 182 size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) { |
183 #if defined(OS_IOS) | 183 #if defined(OS_IOS) |
184 return 0; | 184 return 0; |
185 #else | 185 #else |
186 // The Mac OS X default for a pthread stack size is 512kB. | 186 // The Mac OS X default for a pthread stack size is 512kB. |
187 // Libc-594.1.4/pthreads/pthread.c's pthread_attr_init uses | 187 // Libc-594.1.4/pthreads/pthread.c's pthread_attr_init uses |
(...skipping 26 matching lines...) Expand all Loading... |
214 #endif | 214 #endif |
215 } | 215 } |
216 | 216 |
217 void InitOnThread() { | 217 void InitOnThread() { |
218 } | 218 } |
219 | 219 |
220 void TerminateOnThread() { | 220 void TerminateOnThread() { |
221 } | 221 } |
222 | 222 |
223 } // namespace base | 223 } // namespace base |
OLD | NEW |