| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // Attach the worker thread checker to this thread. | 214 // Attach the worker thread checker to this thread. |
| 215 RTC_DCHECK(spawned_thread_checker_.CalledOnValidThread()); | 215 RTC_DCHECK(spawned_thread_checker_.CalledOnValidThread()); |
| 216 rtc::SetCurrentThreadName(name_.c_str()); | 216 rtc::SetCurrentThreadName(name_.c_str()); |
| 217 | 217 |
| 218 if (run_function_) { | 218 if (run_function_) { |
| 219 SetPriority(priority_); | 219 SetPriority(priority_); |
| 220 run_function_(obj_); | 220 run_function_(obj_); |
| 221 return; | 221 return; |
| 222 } | 222 } |
| 223 // TODO(tommi): Delete the below. | 223 // TODO(tommi): Delete the below. |
| 224 #if !defined(WEBRTC_MAC) && !defined(WEBRTC_WIN) |
| 225 const struct timespec ts_null = {0}; |
| 226 #endif |
| 224 do { | 227 do { |
| 225 // The interface contract of Start/Stop is that for a successful call to | 228 // The interface contract of Start/Stop is that for a successful call to |
| 226 // Start, there should be at least one call to the run function. So we | 229 // Start, there should be at least one call to the run function. So we |
| 227 // call the function before checking |stop_|. | 230 // call the function before checking |stop_|. |
| 228 if (!run_function_deprecated_(obj_)) | 231 if (!run_function_deprecated_(obj_)) |
| 229 break; | 232 break; |
| 230 #if defined(WEBRTC_WIN) | 233 #if defined(WEBRTC_WIN) |
| 231 // Alertable sleep to permit RaiseFlag to run and update |stop_|. | 234 // Alertable sleep to permit RaiseFlag to run and update |stop_|. |
| 232 SleepEx(0, true); | 235 SleepEx(0, true); |
| 233 } while (!stop_); | 236 } while (!stop_); |
| 234 #else | 237 #else |
| 238 #if defined(WEBRTC_MAC) |
| 235 sched_yield(); | 239 sched_yield(); |
| 240 #else |
| 241 nanosleep(&ts_null, nullptr); |
| 242 #endif |
| 236 } while (!AtomicOps::AcquireLoad(&stop_flag_)); | 243 } while (!AtomicOps::AcquireLoad(&stop_flag_)); |
| 237 #endif // defined(WEBRTC_WIN) | 244 #endif // defined(WEBRTC_WIN) |
| 238 } | 245 } |
| 239 | 246 |
| 240 bool PlatformThread::SetPriority(ThreadPriority priority) { | 247 bool PlatformThread::SetPriority(ThreadPriority priority) { |
| 241 #if RTC_DCHECK_IS_ON | 248 #if RTC_DCHECK_IS_ON |
| 242 if (run_function_) { | 249 if (run_function_) { |
| 243 // The non-deprecated way of how this function gets called, is that it must | 250 // The non-deprecated way of how this function gets called, is that it must |
| 244 // be called on the worker thread itself. | 251 // be called on the worker thread itself. |
| 245 RTC_DCHECK(spawned_thread_checker_.CalledOnValidThread()); | 252 RTC_DCHECK(spawned_thread_checker_.CalledOnValidThread()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 #if defined(WEBRTC_WIN) | 312 #if defined(WEBRTC_WIN) |
| 306 bool PlatformThread::QueueAPC(PAPCFUNC function, ULONG_PTR data) { | 313 bool PlatformThread::QueueAPC(PAPCFUNC function, ULONG_PTR data) { |
| 307 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 314 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 308 RTC_DCHECK(IsRunning()); | 315 RTC_DCHECK(IsRunning()); |
| 309 | 316 |
| 310 return QueueUserAPC(function, thread_, data) != FALSE; | 317 return QueueUserAPC(function, thread_, data) != FALSE; |
| 311 } | 318 } |
| 312 #endif | 319 #endif |
| 313 | 320 |
| 314 } // namespace rtc | 321 } // namespace rtc |
| OLD | NEW |