#import "MainThread.h"
#import <Foundation/NSThread.h>
+#import <wtf/Assertions.h>
@interface WTFMainThreadCaller : NSObject {
}
namespace WTF {
+static WTFMainThreadCaller* staticMainThreadCaller = nil;
+#if USE(WEB_THREAD)
+static NSThread* webThread = nil;
+#endif
+
+void initializeMainThreadPlatform()
+{
+ ASSERT(!staticMainThreadCaller);
+ staticMainThreadCaller = [[WTFMainThreadCaller alloc] init];
+
+#if USE(WEB_THREAD)
+ webThread = [[NSThread currentThread] retain];
+#endif
+}
+
void scheduleDispatchFunctionsOnMainThread()
{
- WTFMainThreadCaller *caller = [[WTFMainThreadCaller alloc] init];
- [caller performSelectorOnMainThread:@selector(call) withObject:nil waitUntilDone:NO];
- [caller release];
+ ASSERT(staticMainThreadCaller);
+#if USE(WEB_THREAD)
+ [staticMainThreadCaller performSelector:@selector(call) onThread:webThread withObject:nil waitUntilDone:NO];
+#else
+ [staticMainThreadCaller performSelectorOnMainThread:@selector(call) withObject:nil waitUntilDone:NO];
+#endif
}
} // namespace WTF