Addresses some native component loader thread issues. Makes use of the threadsafe version of nsISupports. Adds comments to IDL it indicate that AutoRegister can only be called from the main thread. See 98755 for details. r=jband@netscape.com, sr=waterson@netscape.com

This commit is contained in:
dougt%netscape.com 2002-04-15 22:36:59 +00:00
parent dbf3500843
commit cfa91392a7
2 changed files with 16 additions and 10 deletions

View File

@ -56,6 +56,8 @@ interface nsIComponentRegistrar : nsISupports
* symbols which this loader defines. For example, if the given file is a
* native library (which is built into XPCOM), it must export the symbol
* "NSGetModule". Other loaders may have different semantics.
*
* This method may only be called from the main thread.
*
* @param aSpec : Filename spec for component file's location. If aSpec
* is a directory, then every component file in the
@ -73,6 +75,7 @@ interface nsIComponentRegistrar : nsISupports
* autoUnregister
*
* Unregister a component file or all component files in a directory.
* This method may only be called from the main thread.
*
* @param aSpec : Filename spec for component file's location. If aSpec
* is a directory, the every component file in the directory

View File

@ -41,7 +41,6 @@
#include "nsHashtableEnumerator.h"
#include "nsXPIDLString.h"
#include "nsCRT.h"
#include "nsIObserverService.h"
#if defined(XP_MAC) // sdagley dougt fix
@ -87,7 +86,7 @@ nsNativeComponentLoader::~nsNativeComponentLoader()
delete mDllStore;
}
NS_IMPL_ISUPPORTS1(nsNativeComponentLoader, nsIComponentLoader);
NS_IMPL_THREADSAFE_ISUPPORTS1(nsNativeComponentLoader, nsIComponentLoader);
NS_IMETHODIMP
nsNativeComponentLoader::GetFactory(const nsIID & aCID,
@ -180,14 +179,17 @@ nsNativeComponentLoader::Init(nsIComponentManager *aCompMgr, nsISupports *aReg)
if (NS_FAILED(rv))
return rv;
if (!mDllStore) {
mDllStore = new nsObjectHashtable(nsnull, nsnull, // never copy
nsDll_Destroy, nsnull,
256, /* Thead Safe */ PR_TRUE);
if (!mDllStore)
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ASSERTION(!mDllStore, "Init must not be called more than once");
mDllStore = new nsObjectHashtable(nsnull,
nsnull, // never copy
nsDll_Destroy,
nsnull,
256,
PR_TRUE); // thread safe
if (!mDllStore)
return NS_ERROR_OUT_OF_MEMORY;
// Read in all dll entries and populate the mDllStore
nsCOMPtr<nsIEnumerator> dllEnum;
@ -979,13 +981,14 @@ nsNativeComponentLoader::RegisterDeferredComponents(PRInt32 aWhen,
mDeferredComponents.RemoveElementAt(i);
}
}
#ifdef DEBUG
if (*aRegistered)
fprintf(stderr, "nNCL: registered deferred, %d left\n",
mDeferredComponents.Count());
else
fprintf(stderr, "nNCL: didn't register any components, %d left\n",
mDeferredComponents.Count());
#endif
/* are there any fatal errors? */
return NS_OK;
}