Re: Seeking advice on NSLock usage
Re: Seeking advice on NSLock usage
- Subject: Re: Seeking advice on NSLock usage
- From: Guy English <email@hidden>
- Date: Mon, 13 Dec 2004 14:48:42 -0500
On Mon, 13 Dec 2004 11:54:51 +0000, Jeremy Dronfield
<email@hidden> wrote:
> On further reflection, I may offer both approaches as a user option. If
> my search thread uses the original model instance, the practical side
> effect is that the user can "tune" their search criteria on the fly,
> while a search is in progress. In some situations I could see this
> being a useful option.
Uh ... wait a second. If your search is going to be running in another
thread and you want to alter the parameters while it's running then
you'll definately need a lock. Changing objects that a thread may be
reading from is bad mojo. Consider:
main thread:
[newCriteria retain];
[criteria release];
search thread then decides to run:
if ( [criteria isEqualTo: @"blah"] ) // app explodes here 'cause
criteria has been released.
main thread:
criteria = newCriteria; // too little to late.
Make sure you put locks around stuff that's going to be accessed by
both threads.
Guy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden