• 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: NSLock locking order;
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSLock locking order;


  • Subject: Re: NSLock locking order;
  • From: Shawn Erickson <email@hidden>
  • Date: Mon, 14 Nov 2005 09:09:40 -0800


On Nov 14, 2005, at 8:47 AM, Matt Budd (Madentec) wrote:

Hey Alastair,

Thanks for the tip...this actually works great. By setting a regular boolean instance variable, I am in effect defining a queue order for the worker thread. So the main thread is blocking waiting to be allowed to update the state, but the worker thread won't continue if there is this update waiting. This works even if the worker thread gets swapped in a couple of times before the main thread can get back to updating the state.

I'm still wondering why this works and just locks doesn't, but I guess it is because the lock by itself is not enough to signal order and we have to add this extra flag.

Consider leveraging a read / write lock if your start to get into multiple threads (not knowing exactly your usage model). You can use what exists at the "darwin" layer for this purpose and even wrap it with a nice Objective-C object if you want... likely can find one out in the wild. Review the following...


<http://developer.apple.com/documentation/Darwin/Conceptual/ KernelProgramming/synchronization/chapter_15_section_4.html#// apple_ref/doc/uid/TP30000905-CH218-CJHFIAEH>
_______________________________________________
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: NSLock locking order;
      • From: Alastair Houghton <email@hidden>
References: 
 >NSLock locking order; (From: "Matt Budd (Madentec)" <email@hidden>)
 >Re: NSLock locking order; (From: Joseph Kelly <email@hidden>)
 >Re: NSLock locking order; (From: Matt Budd (Madentec) <email@hidden>)
 >Re: NSLock locking order; (From: Joseph Kelly <email@hidden>)
 >Re: NSLock locking order; (From: "Matt Budd (Madentec)" <email@hidden>)
 >Re: NSLock locking order; (From: Alastair Houghton <email@hidden>)
 >Re: NSLock locking order; (From: "Matt Budd (Madentec)" <email@hidden>)

  • Prev by Date: Re: NSLock locking order;
  • Next by Date: Re: NSLock locking order;
  • Previous by thread: Re: NSLock locking order;
  • Next by thread: Re: NSLock locking order;
  • Index(es):
    • Date
    • Thread