Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: webrtc/base/thread_darwin.mm

Issue 2833993003: Move autowrap from ThreadManager constructor to Thread::Current. (Closed)
Patch Set: Limit autowrap to main thread only. New method ThreadManager::IsMainThread. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/thread.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 21 matching lines...) Expand all
32 } 32 }
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 main_thread_ref_ = CurrentThreadRef();
42 pthread_key_create(&key_, nullptr); 43 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 44 // This is necessary to alert the cocoa runtime of the fact that
47 // we are running in a multithreaded environment. 45 // we are running in a multithreaded environment.
48 InitCocoaMultiThreading(); 46 InitCocoaMultiThreading();
49 } 47 }
50 48
51 ThreadManager::~ThreadManager() {
52 @autoreleasepool {
53 UnwrapCurrentThread();
54 pthread_key_delete(key_);
55 }
56 }
57
58 // static 49 // static
59 void* Thread::PreRun(void* pv) { 50 void* Thread::PreRun(void* pv) {
60 ThreadInit* init = static_cast<ThreadInit*>(pv); 51 ThreadInit* init = static_cast<ThreadInit*>(pv);
61 ThreadManager::Instance()->SetCurrentThread(init->thread); 52 ThreadManager::Instance()->SetCurrentThread(init->thread);
62 rtc::SetCurrentThreadName(init->thread->name_.c_str()); 53 rtc::SetCurrentThreadName(init->thread->name_.c_str());
63 @autoreleasepool { 54 @autoreleasepool {
64 if (init->runnable) { 55 if (init->runnable) {
65 init->runnable->Run(init->thread); 56 init->runnable->Run(init->thread);
66 } else { 57 } else {
67 init->thread->Run(); 58 init->thread->Run();
(...skipping 16 matching lines...) Expand all
84 75
85 if (cmsLoop != kForever) { 76 if (cmsLoop != kForever) {
86 cmsNext = static_cast<int>(TimeUntil(msEnd)); 77 cmsNext = static_cast<int>(TimeUntil(msEnd));
87 if (cmsNext < 0) 78 if (cmsNext < 0)
88 return true; 79 return true;
89 } 80 }
90 } 81 }
91 } 82 }
92 } 83 }
93 } // namespace rtc 84 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698