Changeset 263723 in webkit
- Timestamp:
- Jun 29, 2020 9:25:52 PM (4 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r263718 r263723 1 2020-06-29 Geoffrey Garen <ggaren@apple.com> 2 3 [GTK] [Win] Build callOnMainThread on WTF::RunLoop rather than on a timer 4 https://bugs.webkit.org/show_bug.cgi?id=213694 5 6 Reviewed by Carlos Garcia Campos. 7 8 As of https://bugs.webkit.org/show_bug.cgi?id=213063, Darwin platforms 9 use the RunLoop. Let's match them for consistency, and to delete some 10 code. 11 12 * wtf/generic/MainThreadGeneric.cpp: 13 (WTF::scheduleDispatchFunctionsOnMainThread): 14 (WTF::MainThreadDispatcher::MainThreadDispatcher): Deleted. 15 (WTF::MainThreadDispatcher::schedule): Deleted. 16 (WTF::MainThreadDispatcher::fired): Deleted. 17 * wtf/glib/RunLoopSourcePriority.h: 18 * wtf/win/MainThreadWin.cpp: 19 (WTF::initializeMainThreadPlatform): 20 (WTF::scheduleDispatchFunctionsOnMainThread): 21 (WTF::ThreadingWindowWndProc): Deleted. 22 1 23 2020-06-29 Guowei Yang <guowei_yang@apple.com> 2 24 -
trunk/Source/WTF/wtf/cf/RunLoopCF.cpp
r252124 r263723 84 84 // RunLoop::Timer 85 85 86 void RunLoop::TimerBase::timerFired(CFRunLoopTimerRef , void* context)86 void RunLoop::TimerBase::timerFired(CFRunLoopTimerRef cfTimer, void* context) 87 87 { 88 88 TimerBase* timer = static_cast<TimerBase*>(context); 89 89 90 90 AutodrainedPool pool; 91 92 if (!CFRunLoopTimerDoesRepeat(cfTimer)) 93 timer->stop(); 94 91 95 timer->fired(); 92 96 } -
trunk/Source/WTF/wtf/generic/MainThreadGeneric.cpp
r251164 r263723 38 38 39 39 #include <wtf/RunLoop.h> 40 #include <wtf/NeverDestroyed.h>41 #if USE(GLIB)42 #include <wtf/glib/RunLoopSourcePriority.h>43 #endif44 40 45 41 namespace WTF { … … 48 44 static pthread_t mainThread; 49 45 #endif 50 51 class MainThreadDispatcher {52 WTF_MAKE_FAST_ALLOCATED;53 public:54 MainThreadDispatcher()55 : m_timer(RunLoop::main(), this, &MainThreadDispatcher::fired)56 {57 #if USE(GLIB)58 m_timer.setPriority(RunLoopSourcePriority::MainThreadDispatcherTimer);59 #endif60 }61 62 void schedule()63 {64 m_timer.startOneShot(0_s);65 }66 67 private:68 void fired()69 {70 dispatchFunctionsFromMainThread();71 }72 73 RunLoop::Timer<MainThreadDispatcher> m_timer;74 };75 46 76 47 void initializeMainThreadPlatform() … … 92 63 void scheduleDispatchFunctionsOnMainThread() 93 64 { 94 // Use a RunLoop::Timer instead of RunLoop::dispatch() to be able to use a different priority and 95 // avoid the double queue because dispatchOnMainThread also queues the functions. 96 static NeverDestroyed<MainThreadDispatcher> dispatcher; 97 dispatcher.get().schedule(); 65 RunLoop::main().dispatch(dispatchFunctionsFromMainThread); 98 66 } 99 67 -
trunk/Source/WTF/wtf/glib/RunLoopSourcePriority.h
r262973 r263723 49 49 JavascriptTimer = 200, 50 50 51 // callOnMainThread.52 MainThreadDispatcherTimer = 100,53 54 51 // Memory pressure monitor. 55 52 MemoryPressureHandlerTimer = -100, … … 89 86 RunLoopTimer = 0, 90 87 91 MainThreadDispatcherTimer = 10,92 93 88 MemoryPressureHandlerTimer = -10, 94 89 -
trunk/Source/WTF/wtf/win/MainThreadWin.cpp
r261393 r263723 38 38 namespace WTF { 39 39 40 static HWND threadingWindowHandle;41 static UINT threadingFiredMessage;42 const LPCWSTR kThreadingWindowClassName = L"ThreadingWindowClass";43 40 static ThreadIdentifier mainThread { 0 }; 44 45 LRESULT CALLBACK ThreadingWindowWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)46 {47 if (message == threadingFiredMessage)48 dispatchFunctionsFromMainThread();49 else50 return DefWindowProc(hWnd, message, wParam, lParam);51 return 0;52 }53 41 54 42 void initializeMainThreadPlatform() 55 43 { 56 if (threadingWindowHandle)57 return;58 59 WNDCLASSW wcex;60 memset(&wcex, 0, sizeof(WNDCLASSW));61 wcex.lpfnWndProc = ThreadingWindowWndProc;62 wcex.lpszClassName = kThreadingWindowClassName;63 RegisterClassW(&wcex);64 65 threadingWindowHandle = CreateWindowW(kThreadingWindowClassName, nullptr, 0,66 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, HWND_MESSAGE, nullptr, nullptr, nullptr);67 threadingFiredMessage = RegisterWindowMessageW(L"com.apple.WebKit.MainThreadFired");68 69 44 mainThread = Thread::currentID(); 70 71 45 Thread::initializeCurrentThreadInternal("Main Thread"); 72 46 RunLoop::registerRunLoopMessageWindowClass(); … … 80 54 void scheduleDispatchFunctionsOnMainThread() 81 55 { 82 ASSERT(threadingWindowHandle); 83 PostMessage(threadingWindowHandle, threadingFiredMessage, 0, 0); 56 RunLoop::main().dispatch(dispatchFunctionsFromMainThread); 84 57 } 85 58
Note: See TracChangeset
for help on using the changeset viewer.