]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - wtf/MainThread.cpp
JavaScriptCore-903.tar.gz
[apple/javascriptcore.git] / wtf / MainThread.cpp
index 1a0682bb6b60c267b40319c3aa6e40cbdb86579d..3229e5b06f315b0c2ec5b4cc860984bca930560a 100644 (file)
@@ -34,6 +34,8 @@
 #include "StdLibExtras.h"
 #include "Threading.h"
 
 #include "StdLibExtras.h"
 #include "Threading.h"
 
+#include <wtf/iphone/WebCoreThread.h>
+
 #if PLATFORM(CHROMIUM)
 #error Chromium uses a different main thread implementation
 #endif
 #if PLATFORM(CHROMIUM)
 #error Chromium uses a different main thread implementation
 #endif
@@ -149,13 +151,14 @@ void dispatchFunctionsFromMainThread()
             MutexLocker locker(mainThreadFunctionQueueMutex());
             if (!functionQueue().size())
                 break;
             MutexLocker locker(mainThreadFunctionQueueMutex());
             if (!functionQueue().size())
                 break;
-            invocation = functionQueue().first();
-            functionQueue().removeFirst();
+            invocation = functionQueue().takeFirst();
         }
 
         invocation.function(invocation.context);
         }
 
         invocation.function(invocation.context);
-        if (invocation.syncFlag)
+        if (invocation.syncFlag) {
+            MutexLocker locker(mainThreadFunctionQueueMutex());
             invocation.syncFlag->signal();
             invocation.syncFlag->signal();
+        }
 
         // If we are running accumulated functions for too long so UI may become unresponsive, we need to
         // yield so the user input can be processed. Otherwise user may not be able to even close the window.
 
         // If we are running accumulated functions for too long so UI may become unresponsive, we need to
         // yield so the user input can be processed. Otherwise user may not be able to even close the window.
@@ -219,7 +222,7 @@ void cancelCallOnMainThread(MainThreadFunction* function, void* context)
 
 void setMainThreadCallbacksPaused(bool paused)
 {
 
 void setMainThreadCallbacksPaused(bool paused)
 {
-    ASSERT(isMainThread());
+    ASSERT((isMainThread() || pthread_main_np()) && WebCoreWebThreadIsLockedOrDisabled());
 
     if (callbacksPaused == paused)
         return;
 
     if (callbacksPaused == paused)
         return;
@@ -230,7 +233,7 @@ void setMainThreadCallbacksPaused(bool paused)
         scheduleDispatchFunctionsOnMainThread();
 }
 
         scheduleDispatchFunctionsOnMainThread();
 }
 
-#if !PLATFORM(MAC) && !PLATFORM(QT)
+#if !PLATFORM(MAC) && !PLATFORM(QT) && !PLATFORM(BREWMP)
 bool isMainThread()
 {
     return currentThread() == mainThreadIdentifier;
 bool isMainThread()
 {
     return currentThread() == mainThreadIdentifier;