X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/9dae56ea45a0f5f8136a5c93d6f3a7f99399ca73..f9bf01c6616d5ddcf65b13b33cedf9e387ff7a63:/wtf/mac/MainThreadMac.mm diff --git a/wtf/mac/MainThreadMac.mm b/wtf/mac/MainThreadMac.mm index b04ef0e..0ddd5f6 100644 --- a/wtf/mac/MainThreadMac.mm +++ b/wtf/mac/MainThreadMac.mm @@ -30,6 +30,7 @@ #import "MainThread.h" #import +#import @interface WTFMainThreadCaller : NSObject { } @@ -47,11 +48,29 @@ 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