• 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: Thread question (volatile needed?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thread question (volatile needed?)


  • Subject: Re: Thread question (volatile needed?)
  • From: Jay Vaughan <email@hidden>
  • Date: Wed, 11 Jun 2003 14:57:07 +0200

My question: Can I be sure that the pointer to "object" is surely
read _after_ my [lock lock] statement? Or could it be that some
compilers (or with some compiler options) this reading may be made
before the locking statement?

Any compiler which switches the order of execution of written code based on a switch is braindead. I certainly hope nothing like this happens with the GCC under OSX!

With the purpose of giving you a hint rather than a solution to your problem, might I suggest that a better question for you to be asking about your problem is this: "Is my lock really locked?"

If one thread has your lock object locked, and another tries to lock it and fails, what happens next in your code?

Re-write your accessor methods to use 'trylock' instead, I would suggest ...

--

;

Jay Vaughan
r&d>>music:technology:synthesizers - www.access-music.de/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Thread question (volatile needed?)
      • From: Marcel Weiher <email@hidden>
References: 
 >Thread question (volatile needed?) (From: Manfred Lippert <email@hidden>)

  • Prev by Date: Re: Cocoa vs Carbon
  • Next by Date: Re: C question for you old guys ;-)
  • Previous by thread: Thread question (volatile needed?)
  • Next by thread: Re: Thread question (volatile needed?)
  • Index(es):
    • Date
    • Thread