Changeset 262904 in webkit
- Timestamp:
- Jun 11, 2020 9:28:32 AM (4 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r262878 r262904 1 2020-06-11 Geoffrey Garen <ggaren@apple.com> 2 3 [Cocoa] Build callOnMainThread on WTF::RunLoop rather than on a timer 4 https://bugs.webkit.org/show_bug.cgi?id=213063 5 6 Reviewed by Anders Carlsson. 7 8 Always use the RunLoop API for main thread tasks. 9 10 Previously, callOnMainThread sometimes scheduled a timer and sometimes 11 used the RunLoop. (Ironically, the timer behavior was added in r55816 12 with the intention to establish a single point of execution. Now, it has 13 the opposite effect.) 14 15 I picked the RunLoop API rather than the timer API because it moves us 16 closer to universally applying the RunLoop speedup in 17 https://bugs.webkit.org/show_bug.cgi?id=202874. Also, it avoids 18 allocating a timer, which can be expensive. 19 20 * wtf/cocoa/MainThreadCocoa.mm: 21 (WTF::scheduleDispatchFunctionsOnMainThread): The webIfExists() check 22 is a superset of the isWebThread() check, so we can just remove the 23 isWebThread() check when scheduling tasks to the web thread. 24 (WTF::timerFired): Deleted. 25 (WTF::postTimer): Deleted. 26 1 27 2020-06-10 Geoffrey Garen <ggaren@apple.com> 2 28 -
trunk/Source/WTF/wtf/cocoa/MainThreadCocoa.mm
r262878 r262904 55 55 #endif 56 56 57 static bool isTimerPosted; // This is only accessed on the main thread.58 59 57 #if USE(WEB_THREAD) 60 58 // When the Web thread is enabled, we consider it to be the main thread, not pthread main. … … 72 70 } 73 71 74 static void timerFired(CFRunLoopTimerRef timer, void*)75 {76 CFRelease(timer);77 isTimerPosted = false;78 79 @autoreleasepool {80 WTF::dispatchFunctionsFromMainThread();81 }82 }83 84 static void postTimer()85 {86 ASSERT(isMainThread());87 88 if (isTimerPosted)89 return;90 91 isTimerPosted = true;92 CFRunLoopAddTimer(CFRunLoopGetCurrent(), CFRunLoopTimerCreate(0, 0, 0, 0, 0, timerFired, 0), kCFRunLoopCommonModes);93 }94 95 72 void scheduleDispatchFunctionsOnMainThread() 96 73 { 97 74 #if USE(WEB_THREAD) 98 if (isWebThread()) {99 postTimer();100 return;101 }102 103 75 if (auto* webRunLoop = RunLoop::webIfExists()) { 104 76 webRunLoop->dispatch(dispatchFunctionsFromMainThread); 105 return;106 }107 #else108 if (isMainThread()) {109 postTimer();110 77 return; 111 78 }
Note: See TracChangeset
for help on using the changeset viewer.