• 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: 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

  • Follow-Ups:
    • Re: Seeking advice on NSLock usage
      • From: Jeremy Dronfield <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>)

  • Prev by Date: How to Get XCode to Really Clean Up
  • Next by Date: Re: How to Get XCode to Really Clean Up
  • Previous by thread: Re: Seeking advice on NSLock usage
  • Next by thread: Re: Seeking advice on NSLock usage
  • Index(es):
    • Date
    • Thread