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

How to tell if there's an active runloop?


  • Subject: How to tell if there's an active runloop?
  • From: Jens Alfke <email@hidden>
  • Date: Wed, 26 Mar 2014 14:33:37 -0700

Is there a way to tell whether the current thread has an active runloop?

I ask because the library that I develop will internally call -performSelector:withObject:afterDelay to schedule an action at a later time. The library can be used on a background thread, with some caveats. A couple of times recently I’ve gotten bug reports where the developer says they never get notifications that the library should be posting; the problem turns out to be that their background thread isn’t running a runloop, so my delayed-performs never trigger.

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?

—Jens
_______________________________________________

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: Charles Srstka <email@hidden>
    • Re: How to tell if there's an active runloop?
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: accessing values along NSIndexPath
  • Next by Date: Re: How to tell if there's an active runloop?
  • Previous by thread: Re: accessing values along NSIndexPath
  • Next by thread: Re: How to tell if there's an active runloop?
  • Index(es):
    • Date
    • Thread