Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Not thread safe events?



On Oct 18, 2005, at 7:27 AM, Eric Schlegel wrote:

Actually, it really has no meaning. It's text that is automatically generated by the tool that generates the header files, but it doesn't really make sense to speak of an event as being thread-safe or thread-unsafe.

Actually, it does.

If an object is thread-safe, it is OK to access that object from multiple threads at once without locking. In other words, the object or the API used to access it performs its own locking as necessary to maintain the object's consistency.

If an object is not thread-safe, it is not OK to access that object from multiple threads at once without locking. In fact, it may not be OK to access that object from any thread but the main thread, since the object may be accessed without locking internally to APIs whose locking behavior a third-party developer cannot control.

There is a third state that's hard to name but easy to describe: An object may not be thread-safe, but may be safe to access from a single thread at once regardless of what that thread is when appropriate locking is used. This is the case if the object's lifecycle and use is controlled by whoever instantiated the object, or if there some other way to share a locking mechanism among all users of the object.

   -- Chris

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >Not thread safe events? (From: Mike Kluev <email@hidden>)
 >Re: Not thread safe events? (From: Eric Schlegel <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.