Re: NSOperation and threadDictionary

2010-09-23 Thread Julien Poissonnier
On Sep 22, 2010, at 12:52 AM, Rick Mann wrote: > Does iOS (and Mac OS X) clean up thread-local storage upon the completion of > an NSOperation? It seems dangerous to rely on every operation to clean up its > own mess. It also seems that an NSOperation should be able to pretend that it > owns t

Re: NSOperation and threadDictionary

2010-09-22 Thread Rick Mann
On Sep 22, 2010, at 16:45:51, Roland King wrote: > I did something similar to this a couple of weeks ago - posted about it but > under a heading about NSManagedObjectWillSave notifications. > > If you have a singleton with a method which returns an MOC, you can store the > MOCs you create in

Re: NSOperation and threadDictionary

2010-09-22 Thread Rick Mann
On Sep 22, 2010, at 17:00:13, Roland King wrote: >> >> Seems reasonable. The only problem I foresee is that if the system is >> recycling threads for subsequent NSOperations, I don't think you'll get the >> NSThreadWillExitNotification, because the thread itself never exits. >> > > Do you ca

Re: NSOperation and threadDictionary

2010-09-22 Thread Roland King
> > Seems reasonable. The only problem I foresee is that if the system is > recycling threads for subsequent NSOperations, I don't think you'll get the > NSThreadWillExitNotification, because the thread itself never exits. > Do you care? In my case I only care that the MOC is appropriate for t

Re: NSOperation and threadDictionary

2010-09-22 Thread Roland King
I did something similar to this a couple of weeks ago - posted about it but under a heading about NSManagedObjectWillSave notifications. If you have a singleton with a method which returns an MOC, you can store the MOCs you create in a CFDictionary in the singleton with the NSThread as key. Th

Re: NSOperation and threadDictionary

2010-09-22 Thread Rick Mann
I knew that wasn't clear. We have a method on the singleton that returns an MOC. If the thread is the main thread, it returns the "main" MOC. If not, it creates a new MOC, and returns that. Then we subsequently pass that MOC around to the various methods responsible for doing the work of creatin

Re: NSOperation and threadDictionary

2010-09-22 Thread Kyle Sluder
On Wed, Sep 22, 2010 at 11:31 AM, Rick Mann 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

Re: NSOperation and threadDictionary

2010-09-22 Thread Rick Mann
On Sep 22, 2010, at 11:17:25, Julien Poissonnier wrote: > > On Sep 22, 2010, at 12:52 AM, Rick Mann wrote: > >> Does iOS (and Mac OS X) clean up thread-local storage upon the completion of >> an NSOperation? It seems dangerous to rely on every operation to clean up >> its own mess. It also se

NSOperation and threadDictionary

2010-09-21 Thread Rick Mann
Does iOS (and Mac OS X) clean up thread-local storage upon the completion of an NSOperation? It seems dangerous to rely on every operation to clean up its own mess. It also seems that an NSOperation should be able to pretend that it owns the thread on which it's running, and not have to worry ab