On Fri, Feb 13, 2009 at 5:21 PM, Ken Thomases <[email protected]> wrote:
>> 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.

If all you need is fire and forget (i.e. you don't need to wait for
the message to complete) then you can do this by simply creating a
timer and adding it to the runloop. Don't forget to call
CFRunLoopWakeUp after you do this. CFRunLoop is thread safe, which
lets you do neat things like this.

(Don't let toll-free bridging confuse you: CFRunLoop is *not*
toll-free bridged to NSRunLoop, and NSRunLoop is *not* thread safe.)

Mike
_______________________________________________

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]

Reply via email to