diff options
| author | Pietro Gagliardi <[email protected]> | 2014-07-08 16:50:52 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-07-08 16:50:52 -0400 |
| commit | edd81e2e48d4e2c14820370dd5829fecaf19d387 (patch) | |
| tree | 9e346e690a022a397f0409bc82e242d14c894751 | |
| parent | b4357db4be6688c67e522b637f100ceecc4a9680 (diff) | |
Switched to using Grand Central Dispatch and Objective-C blocks in the Mac OS X backend. THIS IS PRECEDENT-SETTING.
| -rw-r--r-- | redo/uitask_darwin.m | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/redo/uitask_darwin.m b/redo/uitask_darwin.m index 796bc18..faf78a2 100644 --- a/redo/uitask_darwin.m +++ b/redo/uitask_darwin.m @@ -8,14 +8,6 @@ @end @implementation appDelegateClass - -- (void)issue:(id)obj -{ - NSValue *what = (NSValue *) obj; - - doissue([what pointerValue]); -} - @end appDelegateClass *appDelegate; @@ -40,19 +32,10 @@ void uimsgloop(void) [NSApp run]; } -// Ideally we would have this work like on the other platforms and issue a NSEvent to the end of the event queue -// 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] +// thanks to mikeash in irc.freenode.net/#macdev for suggesting the use of Grand Dispatch and blocks for this void issue(void *what) { - NSAutoreleasePool *p; - NSValue *v; - - p = [NSAutoreleasePool new]; - v = [NSValue valueWithPointer:what]; - [appDelegate performSelectorOnMainThread:@selector(issue:) - withObject:v - waitUntilDone:NO]; - [p release]; + dispatch_async(dispatch_get_main_queue(), ^{ + doissue(what); + }); } |
