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

Re: NSRunLoop question


  • Subject: Re: NSRunLoop question
  • From: Chris Kane <email@hidden>
  • Date: Wed, 14 Aug 2002 11:37:39 -0700

On Wednesday, August 14, 2002, at 11:03 AM, Gerben Wierda wrote:
On Wednesday, August 14, 2002, at 06:15 , Brian Webster wrote:

The docs for -[NSRunLoop run] state "If there are no input sources in the run loop, it exits immediately". So, removing your port from the run loop should cause it to stop running.

Yes, that is what I read too. So, I tried this but I must be doing something wrong, because it does not work.

Well, you have to remember that you are not the only client of the run loop. The libraries you link with may put sources of their own in the run loop. This is one of the strengths of the run loop model, where the list of sources to be waited upon is managed independently of the actual blocking for events, and different parts of a program can operate with event handling independently of each other.

If you want the run loop to terminate, you shouldn't use the run-forever convenience method, -run. Instead, use one of the other run methods and also check other arbitrary conditions of your own, in a loop. A simple example would be:

BOOL shouldKeepRunning = YES; // global

NSRunLoop *theRL = [NSRunLoop currentRunLoop];
while (shouldKeepRunning && [theRL runBeforeDate:[NSDate distantFuture]);


where shouldKeepRunning is set to NO somewhere else in the program.


Chris Kane
Cocoa Frameworks, Apple
_______________________________________________
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: 
 >Re: NSRunLoop question (From: Gerben Wierda <email@hidden>)

  • Prev by Date: Re: NSTask and avoiding buffered standard out
  • Next by Date: setUsesUserKeyEquivalents
  • Previous by thread: Re: NSRunLoop question
  • Next by thread: Re: NSRunLoop question
  • Index(es):
    • Date
    • Thread