Re: NSRunLoop / CFRunLoop
Re: NSRunLoop / CFRunLoop
- Subject: Re: NSRunLoop / CFRunLoop
- From: Ken Thomases <email@hidden>
- Date: Fri, 13 Feb 2009 16:21:01 -0600
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@hidden)
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:
This email sent to email@hidden