Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I’ve had similar issues while trying to manage <code>NSRunLoops</code>. The <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSRunLoop_Class/Reference/Reference.html#//apple_ref/doc/uid/20000321-CHDDBFEA" rel="nofollow noreferrer">discussion</a> for <code>runMode:beforeDate:</code> on the class references page says:</p> <blockquote> <p>If no input sources or timers are attached to the run loop, this method exits immediately; otherwise, it returns after either the first input source is processed or limitDate is reached. Manually removing all known input sources and timers from the run loop is not a guarantee that the run loop will exit. Mac OS X may install and remove additional input sources as needed to process requests targeted at the receiver’s thread. Those sources could therefore prevent the run loop from exiting.</p> </blockquote> <p>My best guess is that an input source is attached to your <code>NSRunLoop</code>, perhaps by OS X itself, and that <code>runMode:beforeDate:</code> is blocking until that input source either has some input processed, or is removed. In your case it was taking "<em>couple of seconds and up to 10 seconds</em>" for this to happen, at which point <code>runMode:beforeDate:</code> would return with a boolean, the <code>while()</code> would run again, it would detect that <code>shouldKeepRunning</code> has been set to <code>NO</code>, and the loop would terminate.</p> <p>With your refinement the <code>runMode:beforeDate:</code> will return within 0.1 seconds, regardless of whether or not it has attached input sources or has processed any input. It's an educated guess (I'm not an expert on the run loop internals), but think your refinement is the right way to handle the situation.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload