r=dougt, sr=bryner, a=dbaron
Patch v2 - do event queue creation lazily
This commit is contained in:
mkaply%us.ibm.com 2003-08-15 13:59:39 +00:00
Родитель 8ebab73aa6
Коммит 7755033a04
3 изменённых файлов: 15 добавлений и 19 удалений

Просмотреть файл

@ -127,6 +127,7 @@ static NS_DEFINE_CID(kMemoryCID, NS_MEMORY_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
NS_GENERIC_FACTORY_CONSTRUCTOR(nsProcess);
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsEventQueueServiceImpl, Init);
#include "nsXPCOM.h"
// ds/nsISupportsPrimitives
@ -303,7 +304,7 @@ static const nsModuleComponentInfo components[] = {
#endif
COMPONENT(OBSERVERSERVICE, nsObserverService::Create),
COMPONENT(GENERICFACTORY, nsGenericFactory::Create),
COMPONENT(EVENTQUEUESERVICE, nsEventQueueServiceImpl::Create),
COMPONENT(EVENTQUEUESERVICE, nsEventQueueServiceImplConstructor),
COMPONENT(EVENTQUEUE, nsEventQueueImpl::Create),
COMPONENT(THREAD, nsThread::Create),
COMPONENT(THREADPOOL, nsThreadPool::Create),
@ -563,12 +564,6 @@ nsresult NS_COM NS_InitXPCOM2(nsIServiceManager* *result,
}
#endif
nsCOMPtr<nsIEventQueueService> eventQService(do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv));
if ( NS_FAILED(rv) ) return rv;
rv = eventQService->CreateThreadEventQueue();
if ( NS_FAILED(rv) ) return rv;
if ( NS_FAILED(rv) || CheckAndRemoveUpdateFile()) {
// if we find no persistent registry, we will try to autoregister
// the default components directory.

Просмотреть файл

@ -104,17 +104,19 @@ nsEventQueueServiceImpl::~nsEventQueueServiceImpl()
PR_DestroyMonitor(mEventQMonitor);
}
NS_METHOD
nsEventQueueServiceImpl::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
nsresult
nsEventQueueServiceImpl::Init()
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsEventQueueServiceImpl* eqs = new nsEventQueueServiceImpl();
if (eqs == NULL)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(eqs);
nsresult rv = eqs->QueryInterface(aIID, aResult);
NS_RELEASE(eqs);
// ensure that a main thread event queue exists!
nsresult rv;
nsCOMPtr<nsIThread> mainThread;
rv = nsIThread::GetMainThread(getter_AddRefs(mainThread));
if (NS_SUCCEEDED(rv)) {
PRThread *thr;
rv = mainThread->GetPRThread(&thr);
if (NS_SUCCEEDED(rv))
rv = CreateEventQueue(thr, PR_TRUE);
}
return rv;
}

Просмотреть файл

@ -51,8 +51,7 @@ public:
nsEventQueueServiceImpl();
virtual ~nsEventQueueServiceImpl();
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
nsresult Init();
// nsISupports interface...
NS_DECL_ISUPPORTS