• 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 Safety
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thread Safety


  • Subject: Re: Thread Safety
  • From: Chris Hanson <email@hidden>
  • Date: Wed, 20 Jun 2007 14:37:29 -0700

On Jun 20, 2007, at 8:37 AM, Yves Poissant wrote:

Some other functions don't have this topic. What is to be assumed in those cases? Obviously, the safest bet is to assume that those functions are not thread safe. But is that the correct assumption?

It's a necessary but not sufficient assumption. In the absence of specific information to the contrary, you must assume that a function, method, or data structure:


(1) Cannot itself be invoked from multiple threads at once. This is the traditional definition of "thread-safe."

(2) Cannot be made thread-safe by locking or synchronizing around its use. This is because you may not control all call sites, and cannot force everything to use your locking or synchronization mechanism.

(3) As a consequence of #1 and #2, it cannot be used or invoked on any thread other than the main thread.

I have seen a truly disturbing number of situations where people try to "make" a facility "thread-safe" by surrounding its use with locks. Since you can't control every call site, this is a recipe for disaster.

  -- Chris

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Thread Safety
      • From: Scott Ribe <email@hidden>
References: 
 >Orange breakpoint (From: "Yves Poissant" <email@hidden>)
 >Re: Orange breakpoint (From: "R. Matthew Emerson" <email@hidden>)
 >Re: Orange breakpoint (From: "Yves Poissant" <email@hidden>)
 >Thread Safety (From: "Yves Poissant" <email@hidden>)

  • Prev by Date: Re: Enabling Preferences
  • Next by Date: Re: So I'm a n00b...
  • Previous by thread: Re: Thread Safety
  • Next by thread: Re: Thread Safety
  • Index(es):
    • Date
    • Thread