Re: Thread safety with background fetching
Re: Thread safety with background fetching
- Subject: Re: Thread safety with background fetching
- From: Joseph Kelly <email@hidden>
- Date: Thu, 31 Jul 2008 16:28:15 -0700
Jens response just reminded me to check the docs, and it says of -
performSelectorOnMainThread:...:
"This method retains the receiver and the arg parameter until after
the selector is performed"
So I retract what I said before. So long as, was noted, you do not
mess with the passed object in the worker thread AFTER you send it to
the main thread, you should be all good.
Joe K.
On Jul 31, 2008, at 4:14 PM, Joseph Kelly wrote:
The only time you're sharing data across threads is via -
performSelectorOnMainThread:... which itself is thread safe.
So the main thing you have to work through is the memory management
of the data which XMLFetcherParser is passing to the -receiveItem:
method on the main thread. The convention is that things are created
and immediately added to the autorelease pool.
For instance, If the worker thread's autorelease pool gets released
right after it passes you the object on the main thread, that object
will become released, and you're left with a dangling pointer.
You might need to adopt a very tight convention that you retain the
object before sending it to the main thread, and once in the main
thread, autorelease it there.
Joe K.
On Jul 31, 2008, at 9:59 AM, Ben wrote:
_______________________________________________
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