• 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: How to tell if there's an active runloop?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to tell if there's an active runloop?


  • Subject: Re: How to tell if there's an active runloop?
  • From: Kyle Sluder <email@hidden>
  • Date: Wed, 26 Mar 2014 14:48:15 -0700

On Wed, Mar 26, 2014, at 02:33 PM, Jens Alfke wrote:
> I’d like to be able to detect this situation and log a warning or throw
> an exception. But I can’t figure out what to check. I know that
> [NSRunLoop currentRunLoop] will create a new runloop for the current
> thread if one doesn’t exist, so it never returns nil. Will looking at its
> -currentMode help? Or should I bridge over to CFRunLoop and check whether
> there are any attached sources?

This smells like a really bad design.

The concept of an "active" runloop doesn't actually map to anything that
accurately describes the system. Some code might use
-runMode:beforeDate: to process a single event at a time. That code
might be invoked by code that's running a runloop via -run. And the
runloop might _never_ run in the mode in which you post your
-performSelector:afterDelay:.

If you want to delay something for later, you should probably use
dispatch_after.

--Kyle Sluder

_______________________________________________

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


  • Follow-Ups:
    • Re: How to tell if there's an active runloop?
      • From: Ken Thomases <email@hidden>
    • Re: How to tell if there's an active runloop?
      • From: Jens Alfke <email@hidden>
References: 
 >How to tell if there's an active runloop? (From: Jens Alfke <email@hidden>)

  • Prev by Date: How to tell if there's an active runloop?
  • Next by Date: Re: How to tell if there's an active runloop?
  • Previous by thread: How to tell if there's an active runloop?
  • Next by thread: Re: How to tell if there's an active runloop?
  • Index(es):
    • Date
    • Thread