Re: Thread safety of Bonjour Cocoa classes? (NSNetService, etc.)
Re: Thread safety of Bonjour Cocoa classes? (NSNetService, etc.)
- Subject: Re: Thread safety of Bonjour Cocoa classes? (NSNetService, etc.)
- From: Chris Parker <email@hidden>
- Date: Thu, 14 Feb 2013 12:47:13 -0800
On 14 Feb 2013, at 11:26 AM, Sean McBride <email@hidden> wrote:
> Anyone tried using NSNetService and NSNetServiceBrowser on non-main threads on OS X?
>
> - the 'Thread Safety Summary' document does not mention these classes.
> - NSNetServices.h says "NSNetService instances may be scheduled on NSRunLoops to operate in different modes, or in other threads. It is generally not necessary to schedule NSNetServices in other threads."
> - CFNetServices.h documents pretty much every API as 'Thread safe', and if the NS version is a wrapper over the CF version... (actually, I can't find a doc saying these are toll free bridged either.)
>
> I've having intermitting issues where my delegate methods are sometimes not being called, and I wonder if it's because I'm using a non-main thread/runloop.
NSNetService (and NSNetServiceBrowser) automatically schedules itself on the run loop of the thread it's being created on. If the run loop isn't being spun (e.g. on a thread created by detaching a pthread or an NSThread) then you won't get callbacks.
.chris
_______________________________________________
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