Re: NSOperation and threadDictionary
Re: NSOperation and threadDictionary
- Subject: Re: NSOperation and threadDictionary
- From: Kyle Sluder <email@hidden>
- Date: Wed, 22 Sep 2010 11:43:45 -0700
On Wed, Sep 22, 2010 at 11:31 AM, Rick Mann <email@hidden> wrote:
> Pity. We have a singleton object that creates a subclass of NSOperation, which then calls back a method on the singleton that's intended to be run on a separate thread (provided indirectly by the NSOperation). That singleton needs it's own NSManagedObjectContext, which we were creating and then passing around to everything the singleton called. We wanted to avoid the danger of creating additional ones by storing it in TLS, but I guess we're not supposed to do that (although it does talk about data that you "create yourself or manage," which is the case here).
You wanted to avoid the danger of creating additional
NSManagedObjectContexts? As far as I understand your design, you need
to create a new MOC for every NSOperation instance, regardless of what
thread it winds up being executed on. Theoretically, you'll never even
spawn another thread; you might be running on a Core Solo, and GCD
and/or NSOperationQueue might just run everything on the main thread.
(I don't know if that's actually possible; GCD operations might always
run on a background thread, but I can certainly foresee the system
deciding not to create more than one background thread on a
single-core Mac.)
--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