• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Seeking advice on NSLock usage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Seeking advice on NSLock usage


  • Subject: Re: Seeking advice on NSLock usage
  • From: Jeremy Dronfield <email@hidden>
  • Date: Mon, 13 Dec 2004 22:07:37 +0000


On 13 Dec 2004, at 7:48 pm, Guy English wrote:

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.

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
_______________________________________________
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


References: 
 >Seeking advice on NSLock usage (From: Jeremy Dronfield <email@hidden>)
 >Re: Seeking advice on NSLock usage (From: Andreas Mayer <email@hidden>)
 >Re: Seeking advice on NSLock usage (From: Jeremy Dronfield <email@hidden>)
 >Re: Seeking advice on NSLock usage (From: Guy English <email@hidden>)

  • Prev by Date: Sound in TextView
  • Next by Date: Chatter from debug frameworks
  • Previous by thread: Re: Seeking advice on NSLock usage
  • Next by thread: Re: How can I implement labels without the overhead of an NSTextField?
  • Index(es):
    • Date
    • Thread