Title: [262977] trunk/Source/WTF
Revision
262977
Author
lawrenc...@apple.com
Date
2020-06-12 14:58:25 -0700 (Fri, 12 Jun 2020)

Log Message

Unreviewed, reverting r262904.

This commit broke a test on Mac wk1 Debug.

Reverted changeset:

"[Cocoa] Build callOnMainThread on WTF::RunLoop rather than on
a timer"
https://bugs.webkit.org/show_bug.cgi?id=213063
https://trac.webkit.org/changeset/262904

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (262976 => 262977)


--- trunk/Source/WTF/ChangeLog	2020-06-12 21:03:05 UTC (rev 262976)
+++ trunk/Source/WTF/ChangeLog	2020-06-12 21:58:25 UTC (rev 262977)
@@ -1,3 +1,16 @@
+2020-06-12  Jason Lawrence  <lawrenc...@apple.com>
+
+        Unreviewed, reverting r262904.
+
+        This commit broke a test on Mac wk1 Debug.
+
+        Reverted changeset:
+
+        "[Cocoa] Build callOnMainThread on WTF::RunLoop rather than on
+        a timer"
+        https://bugs.webkit.org/show_bug.cgi?id=213063
+        https://trac.webkit.org/changeset/262904
+
 2020-06-12  Adrian Perez de Castro  <ape...@igalia.com>
 
         Build is broken with EVENT_LOOP_TYPE=GLib

Modified: trunk/Source/WTF/wtf/cocoa/MainThreadCocoa.mm (262976 => 262977)


--- trunk/Source/WTF/wtf/cocoa/MainThreadCocoa.mm	2020-06-12 21:03:05 UTC (rev 262976)
+++ trunk/Source/WTF/wtf/cocoa/MainThreadCocoa.mm	2020-06-12 21:58:25 UTC (rev 262977)
@@ -54,6 +54,8 @@
 WTFLogChannel LogThreading = { WTFLogChannelState::On, "Threading", WTFLogLevel::Error, LOG_CHANNEL_WEBKIT_SUBSYSTEM, OS_LOG_DEFAULT };
 #endif
 
+static bool isTimerPosted; // This is only accessed on the main thread.
+
 #if USE(WEB_THREAD)
 // When the Web thread is enabled, we consider it to be the main thread, not pthread main.
 static pthread_t s_webThreadPthread;
@@ -69,13 +71,44 @@
     ASSERT(pthread_main_np());
 }
 
+static void timerFired(CFRunLoopTimerRef timer, void*)
+{
+    CFRelease(timer);
+    isTimerPosted = false;
+
+    @autoreleasepool {
+        WTF::dispatchFunctionsFromMainThread();
+    }
+}
+
+static void postTimer()
+{
+    ASSERT(isMainThread());
+
+    if (isTimerPosted)
+        return;
+
+    isTimerPosted = true;
+    CFRunLoopAddTimer(CFRunLoopGetCurrent(), CFRunLoopTimerCreate(0, 0, 0, 0, 0, timerFired, 0), kCFRunLoopCommonModes);
+}
+
 void scheduleDispatchFunctionsOnMainThread()
 {
 #if USE(WEB_THREAD)
+    if (isWebThread()) {
+        postTimer();
+        return;
+    }
+
     if (auto* webRunLoop = RunLoop::webIfExists()) {
         webRunLoop->dispatch(dispatchFunctionsFromMainThread);
         return;
     }
+#else
+    if (isMainThread()) {
+        postTimer();
+        return;
+    }
 #endif
 
     RunLoop::main().dispatch(dispatchFunctionsFromMainThread);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to