FROM : Jeremy Dronfield
DATE : Mon Dec 13 23:07:37 2004
On 13 Dec 2004, at 7:48 pm, Guy English wrote:
> On Mon, 13 Dec 2004 11:54:51 +0000, Jeremy Dronfield
> <jeremy.<email_removed>> 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.
Yes, I know. What I said was, I decided to use a copy instead of locks
– but on further reflection I'm considering doing both.
Regards,
Jeremy
DATE : Mon Dec 13 23:07:37 2004
On 13 Dec 2004, at 7:48 pm, Guy English wrote:
> On Mon, 13 Dec 2004 11:54:51 +0000, Jeremy Dronfield
> <jeremy.<email_removed>> 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.
Yes, I know. What I said was, I decided to use a copy instead of locks
– but on further reflection I'm considering doing both.
Regards,
Jeremy
| Related mails | Author | Date |
|---|---|---|
| Jeremy Dronfield | Dec 12, 16:36 | |
| Nick Zitzmann | Dec 12, 18:48 | |
| Clark Cox | Dec 13, 04:34 | |
| Evan Schoenberg | Dec 13, 05:05 | |
| Andreas Mayer | Dec 13, 07:38 | |
| Jeremy Dronfield | Dec 13, 12:54 | |
| Guy English | Dec 13, 20:48 | |
| Jeremy Dronfield | Dec 13, 23:07 |






Cocoa mail archive

