+void initializeMainThreadToProcessMainThreadPlatform()
+{
+ if (!pthread_main_np())
+ NSLog(@"WebKit Threading Violation - initial use of WebKit from a secondary thread.");
+
+ ASSERT(!staticMainThreadCaller);
+ staticMainThreadCaller = [[WTFMainThreadCaller alloc] init];
+
+ mainThreadEstablishedAsPthreadMain = true;
+ mainThreadPthread = 0;
+ mainThreadNSThread = nil;
+}
+
+static void timerFired(CFRunLoopTimerRef timer, void*)
+{
+ CFRelease(timer);
+ isTimerPosted = false;
+ WTF::dispatchFunctionsFromMainThread();
+}
+
+static void postTimer()
+{
+ ASSERT(isMainThread());
+
+ if (isTimerPosted)
+ return;
+
+ isTimerPosted = true;
+ CFRunLoopAddTimer(CFRunLoopGetCurrent(), CFRunLoopTimerCreate(0, 0, 0, 0, 0, timerFired, 0), kCFRunLoopCommonModes);
+}
+