Changeset 262863 in webkit
- Timestamp:
- Jun 10, 2020 3:03:12 PM (4 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r262858 r262863 1 2020-06-10 Geoffrey Garen <ggaren@apple.com> 2 3 [Cocoa] Build callOnMainThread on WTF::RunLoop rather than on NSObject methods 4 https://bugs.webkit.org/show_bug.cgi?id=213043 5 6 Reviewed by Simon Fraser. 7 8 Original patch by Sihui Liu. 9 10 From https://bugs.webkit.org/show_bug.cgi?id=202874, this is the subset 11 of Sihui's patch that unifies some of RunLoop and callOnMainThread. 12 13 My goal is to simplify the code, and shrink the diff when testing 14 CFRunLoopSource1 in the future. 15 16 * wtf/RunLoop.cpp: 17 (WTF::RunLoop::initializeWebRunLoop): 18 (WTF::RunLoop::web): 19 * wtf/RunLoop.h: 20 * wtf/cocoa/MainThreadCocoa.mm: 21 (WTF::initializeMainThreadPlatform): 22 (WTF::scheduleDispatchFunctionsOnMainThread): 23 (WTF::initializeWebThread): 24 (-[JSWTFMainThreadCaller call]): Deleted. 25 1 26 2020-06-10 Jer Noble <jer.noble@apple.com> 2 27 -
trunk/Source/WTF/wtf/RunLoop.cpp
r257142 r262863 34 34 35 35 static RunLoop* s_mainRunLoop; 36 #if USE(WEB_THREAD) 37 static RunLoop* s_webRunLoop; 38 #endif 36 39 37 40 // Helper class for ThreadSpecificData. … … 69 72 return *s_mainRunLoop; 70 73 } 74 75 #if USE(WEB_THREAD) 76 void RunLoop::initializeWebRunLoop() 77 { 78 s_webRunLoop = &RunLoop::current(); 79 } 80 81 RunLoop& RunLoop::web() 82 { 83 ASSERT(s_webRunLoop); 84 return *s_webRunLoop; 85 } 86 #endif 71 87 72 88 bool RunLoop::isMain() -
trunk/Source/WTF/wtf/RunLoop.h
r261569 r262863 62 62 // can be called from any thread). 63 63 WTF_EXPORT_PRIVATE static void initializeMainRunLoop(); 64 #if USE(WEB_THREAD) 65 WTF_EXPORT_PRIVATE static void initializeWebRunLoop(); 66 #endif 64 67 65 68 WTF_EXPORT_PRIVATE static RunLoop& current(); 66 69 WTF_EXPORT_PRIVATE static RunLoop& main(); 70 #if USE(WEB_THREAD) 71 WTF_EXPORT_PRIVATE static RunLoop& web(); 72 #endif 67 73 WTF_EXPORT_PRIVATE static bool isMain(); 68 74 ~RunLoop() final; -
trunk/Source/WTF/wtf/cocoa/MainThreadCocoa.mm
r260366 r262863 37 37 #import <wtf/HashSet.h> 38 38 #import <wtf/RetainPtr.h> 39 #import <wtf/RunLoop.h> 39 40 #import <wtf/SchedulePair.h> 40 41 #import <wtf/Threading.h> … … 43 44 #import <wtf/ios/WebCoreThread.h> 44 45 #endif 45 46 @interface JSWTFMainThreadCaller : NSObject47 - (void)call;48 @end49 50 @implementation JSWTFMainThreadCaller51 52 - (void)call53 {54 WTF::dispatchFunctionsFromMainThread();55 }56 57 @end58 46 59 47 #define LOG_CHANNEL_PREFIX Log … … 67 55 #endif 68 56 69 70 static JSWTFMainThreadCaller* staticMainThreadCaller;71 57 static bool isTimerPosted; // This is only accessed on the main thread. 72 58 … … 85 71 RELEASE_LOG_FAULT(Threading, "WebKit Threading Violation - initial use of WebKit from a secondary thread."); 86 72 ASSERT(pthread_main_np()); 87 88 ASSERT(!staticMainThreadCaller);89 staticMainThreadCaller = [[JSWTFMainThreadCaller alloc] init];90 73 } 91 74 … … 113 96 void scheduleDispatchFunctionsOnMainThread() 114 97 { 115 ASSERT(staticMainThreadCaller);116 117 98 #if USE(WEB_THREAD) 118 99 if (isWebThread()) { … … 122 103 123 104 if (mainThreadPthread) { 124 [staticMainThreadCaller performSelector:@selector(call) onThread:mainThreadNSThread withObject:nil waitUntilDone:NO];105 RunLoop::web().dispatch(dispatchFunctionsFromMainThread); 125 106 return; 126 107 } … … 132 113 #endif 133 114 134 [staticMainThreadCaller performSelectorOnMainThread:@selector(call) withObject:nil waitUntilDone:NO];115 RunLoop::main().dispatch(dispatchFunctionsFromMainThread); 135 116 } 136 117 … … 197 178 mainThreadNSThread = [NSThread currentThread]; 198 179 sWebThread = &Thread::current(); 180 RunLoop::initializeWebRunLoop(); 199 181 }); 200 182 }
Note: See TracChangeset
for help on using the changeset viewer.