• 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 vs. CFRunLoop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSRunLoop vs. CFRunLoop


  • Subject: Re: NSRunLoop vs. CFRunLoop
  • From: Douglas Davidson <email@hidden>
  • Date: Tue, 29 Oct 2002 09:21:39 -0800

On Monday, October 28, 2002, at 02:52 PM, Fritz Anderson wrote:

When I test my code in a Cocoa command-line tool (in which NSApplication is not run, mark you), I find that CFRunLoopRun() does not return, unless I call CFRunLoopStop() in the callback, even if I call CFReadStreamClose() and CFHTTPReadStreamUnscheduleFromRunLoop() -- henceforth C35p() -- on its only registered input. My previous experience was with -[NSRunLoop run], which ordinarily does return whenever it runs out of inputs and tasks.

Run loops generally do stop running when they have no more sources. However, you cannot guarantee that you are the only one adding sources to the run loop. For example, CFNetwork adds sources of its own to the run loop for its own purposes. Therefore you should never rely on being able to stop the run loop by removing all of your sources. CFRunLoopRun() is a convenience function that is most appropriate when you want the run loop to continue running indefinitely. Otherwise, it's probably better to call CFRunLoopRunInMode() inside a loop that checks whatever conditions you may have for wanting the run loop to continue running or not.

Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >NSRunLoop vs. CFRunLoop (From: Fritz Anderson <email@hidden>)

  • Prev by Date: Re: modifying Info.plist at runtime
  • Next by Date: bounds, width & height question
  • Previous by thread: NSRunLoop vs. CFRunLoop
  • Next by thread: EOF API?
  • Index(es):
    • Date
    • Thread