| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2017 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2017 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 22 matching lines...) Expand all Loading... |
| 33 } | 33 } |
| 34 | 34 |
| 35 RTC_DCHECK([NSThread isMultiThreaded]); | 35 RTC_DCHECK([NSThread isMultiThreaded]); |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 | 38 |
| 39 namespace rtc { | 39 namespace rtc { |
| 40 | 40 |
| 41 ThreadManager::ThreadManager() { | 41 ThreadManager::ThreadManager() { |
| 42 pthread_key_create(&key_, nullptr); | 42 pthread_key_create(&key_, nullptr); |
| 43 #ifndef NO_MAIN_THREAD_WRAPPING | |
| 44 WrapCurrentThread(); | |
| 45 #endif | |
| 46 // This is necessary to alert the cocoa runtime of the fact that | 43 // This is necessary to alert the cocoa runtime of the fact that |
| 47 // we are running in a multithreaded environment. | 44 // we are running in a multithreaded environment. |
| 48 InitCocoaMultiThreading(); | 45 InitCocoaMultiThreading(); |
| 49 } | 46 } |
| 50 | 47 |
| 51 ThreadManager::~ThreadManager() { | |
| 52 @autoreleasepool { | |
| 53 UnwrapCurrentThread(); | |
| 54 pthread_key_delete(key_); | |
| 55 } | |
| 56 } | |
| 57 | |
| 58 // static | 48 // static |
| 59 void* Thread::PreRun(void* pv) { | 49 void* Thread::PreRun(void* pv) { |
| 60 ThreadInit* init = static_cast<ThreadInit*>(pv); | 50 ThreadInit* init = static_cast<ThreadInit*>(pv); |
| 61 ThreadManager::Instance()->SetCurrentThread(init->thread); | 51 ThreadManager::Instance()->SetCurrentThread(init->thread); |
| 62 rtc::SetCurrentThreadName(init->thread->name_.c_str()); | 52 rtc::SetCurrentThreadName(init->thread->name_.c_str()); |
| 63 @autoreleasepool { | 53 @autoreleasepool { |
| 64 if (init->runnable) { | 54 if (init->runnable) { |
| 65 init->runnable->Run(init->thread); | 55 init->runnable->Run(init->thread); |
| 66 } else { | 56 } else { |
| 67 init->thread->Run(); | 57 init->thread->Run(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 84 | 74 |
| 85 if (cmsLoop != kForever) { | 75 if (cmsLoop != kForever) { |
| 86 cmsNext = static_cast<int>(TimeUntil(msEnd)); | 76 cmsNext = static_cast<int>(TimeUntil(msEnd)); |
| 87 if (cmsNext < 0) | 77 if (cmsNext < 0) |
| 88 return true; | 78 return true; |
| 89 } | 79 } |
| 90 } | 80 } |
| 91 } | 81 } |
| 92 } | 82 } |
| 93 } // namespace rtc | 83 } // namespace rtc |
| OLD | NEW |