I've read the book "Creating XPCOM Components"
http://www.mozilla.org/projects/xpcom/book/cxc/pdf/cxc.pdf
The book is very useful but thread-safety topic is basically ignored.
So I was wondering if there is a document that describes XPCOM thread-safety
policies?

Do I need to define some special flags when buliding XPCOM to make it
possible to use XPCOM infrastructure in a multithreaded application
(something like _MT=1)? For example, can I call XPCOM object factories and
other global componets such as Components Manager from different threads?
Can I be sure that global parts of XPCOM infrastructure and built-in objects
are thread-safe? Do I need to call XPCOM-init() for each thread that uses
XPCOM or just once for the entire application?

At the moment, my understanding is that the very least I need to do to make
my own custom XPCOM components accessible from multiple threads is to use
threadsafe macros such as NS_IMPL_THREADSAFE_ISUPPORTSN instead of
NS_IMPL_ISUPPORTSN. It disables checking for a single owning thread and it
makes AddRef and Release atomic. Obviously it is up to me to implement
proper locking policy in all custom methods of my home-grown XPCOM objects.
For instance, I could use NSPR synchronization primitives to do so. Is this
correct?



_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to