• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSRunLoop / CFRunLoop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSRunLoop / CFRunLoop


  • Subject: Re: NSRunLoop / CFRunLoop
  • From: Michael Ash <email@hidden>
  • Date: Fri, 13 Feb 2009 17:49:27 -0500

On Fri, Feb 13, 2009 at 5:21 PM, Ken Thomases <email@hidden> 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@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

References: 
 >NSRunLoop / CFRunLoop (From: Alexander Cohen <email@hidden>)
 >Re: NSRunLoop / CFRunLoop (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Programatically Uncheck "Change Picture" In Desktop Settings?
  • Next by Date: alloc/release confusion
  • Previous by thread: Re: NSRunLoop / CFRunLoop
  • Next by thread: Re: NSRunLoop / CFRunLoop
  • Index(es):
    • Date
    • Thread