On Feb 13, 2009, at 2:54 PM, Alexander Cohen wrote:
I'm looking for a way to get the main CFRunLoop on tiger. On leopard, there is a simple call for it but i'm stuck with tiger for now.
Your main thread, before any secondary threads are created, can get its current run loop and stash a reference to it in a global variable.
And while i'm at it, i'd like to do something like [obj performSelectorOnMainThread...] in CoreFoundation using CFRunLoops. I'm sure it's possible but i'm not sure where to start.
You'd create a custom run loop source. It would manage a queue of messages. Access to the queue would have to be properly thread-safe. Your function for queuing a message would put it in the data structure and then signal your run loop source. The "perform" callback of the run loop source would dequeue all of the messages and process them.
What you put in your messages and how you process them is entirely up to you.
There's a dated-but-still-nice bit of code out there called YAMessageQueue. It has an Objective-C interface, but under the hood uses Core Foundation. It might be educational.
Cheers, Ken _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
