• 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: Charles Srstka <email@hidden>
  • Date: Thu, 27 Mar 2014 00:34:45 -0500

On Mar 26, 2014, at 4:33 PM, Jens Alfke <email@hidden> wrote:

> 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?

Maybe the best thing to do is to do what CF/NSStream does, and add a -scheduleInRunLoop:forMode: API, so that the caller can give you an NSRunLoop that he/she/it is guaranteeing is valid?

Charles

_______________________________________________

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


References: 
 >How to tell if there's an active runloop? (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: accessing values along NSIndexPath
  • Next by Date: Re: How to prevent a temp folder from being deleted
  • Previous by thread: Re: How to tell if there's an active runloop?
  • Next by thread: How to prevent a temp folder from being deleted
  • Index(es):
    • Date
    • Thread