"Ken Kozman" <[EMAIL PROTECTED]> writes:
>
> I also noticed when running around the standard NS_IMPL_ADDREF and RELEASE
> macros that they do not do a thread safe increment and decrement on the
> internal ref count. For example:
>
> #define NS_IMPL_ADDREF(_class) \
> NS_IMETHODIMP_(nsrefcnt) _class::AddRef(void) \
> { \
> NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt"); \
> NS_ASSERT_OWNINGTHREAD(_class); \
> ++mRefCnt; \
> NS_LOG_ADDREF(this, mRefCnt, #_class, sizeof(*this)); \
> return mRefCnt; \
> }
>
> Now I do not know what sort of multi threaded stuff is allowed or intended
> for XPCOM, but again under COM this would be a big no-no unless you were
> implementing purely single-threaded objects. Maybe this is the case for most
> of the XPCOM stuff, but it surprises me that there is an
> NS_ASSERT_OWNINGTHREAD( ) call, and then it does not bother to do safe
> increments and decrements (but I'm probably missing something here...)
Classes that are suitably threadsafe should use
NS_IMPL_THREADSAFE_ISUPPORTSx, where x is the number of interfaces
implemented. This will pull in threadsafe implementations of AddRef,
Release, etc.
Dan
- Re: Autoreg, unloading DLLs, and running out of o... Andy
- Re: Autoreg, unloading DLLs, and running out of o... Rick Parrish
- Re: Autoreg, unloading DLLs, and running out of o... Phillip M. Jones, C.E.T.
- Re: Autoreg, unloading DLLs, and running out of o... Steve Dagley
- Re: Autoreg, unloading DLLs, and running out of o... Phillip M. Jones, C.E.T.
- Re: Autoreg, unloading DLLs, and running out of o... Ken Kozman
- Re: Autoreg, unloading DLLs, and running out of o... Simon Fraser
- Re: Autoreg, unloading DLLs, and running out... John Bandhauer
- Re: Autoreg, unloading DLLs, and running out of o... Simon P. Lucy
- Re: Autoreg, unloading DLLs, and running out of o... Ken Kozman
- Re: Autoreg, unloading DLLs, and running out of o... Dan Mosedale
- Re: Autoreg, unloading DLLs, and running out of o... Colin Blake
- Re: Autoreg, unloading DLLs, and running out of o... Simon P. Lucy
- Re: Autoreg, unloading DLLs, and running out of o... Colin Blake
- Re: Autoreg, unloading DLLs, and running out... Simon P. Lucy
- Re: Autoreg, unloading DLLs, and running out of o... Daniel Veditz
