Switched to using Grand Central Dispatch and Objective-C blocks in the Mac OS X backend. THIS IS PRECEDENT-SETTING.

This commit is contained in:
Pietro Gagliardi 2014-07-08 16:50:52 -04:00
parent b4357db4be
commit edd81e2e48
1 changed files with 4 additions and 21 deletions

View File

@ -8,14 +8,6 @@
@end @end
@implementation appDelegateClass @implementation appDelegateClass
- (void)issue:(id)obj
{
NSValue *what = (NSValue *) obj;
doissue([what pointerValue]);
}
@end @end
appDelegateClass *appDelegate; appDelegateClass *appDelegate;
@ -40,19 +32,10 @@ void uimsgloop(void)
[NSApp run]; [NSApp run];
} }
// Ideally we would have this work like on the other platforms and issue a NSEvent to the end of the event queue // thanks to mikeash in irc.freenode.net/#macdev for suggesting the use of Grand Dispatch and blocks for this
// Unfortunately, there doesn't seem to be a way for NSEvents to hold pointer values, only (signed) NSIntegers
// So we'll have to do the performSelectorOnMainThread: approach
// [TODO]
void issue(void *what) void issue(void *what)
{ {
NSAutoreleasePool *p; dispatch_async(dispatch_get_main_queue(), ^{
NSValue *v; doissue(what);
});
p = [NSAutoreleasePool new];
v = [NSValue valueWithPointer:what];
[appDelegate performSelectorOnMainThread:@selector(issue:)
withObject:v
waitUntilDone:NO];
[p release];
} }