From 04e4e1d9d32a122bd013a5fd4375578c2d194704 Mon Sep 17 00:00:00 2001 From: "andreas.otte%primus-online.de" Date: Wed, 2 Jun 1999 11:42:43 +0000 Subject: [PATCH] integrating Alec Fletts nsISupportsArray changes remove manual registration adding creation of eventqueue giving EventQueueService the right CIID git-svn-id: svn://10.0.0.236/trunk@33419 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/netwerk/test/TestFileInput.cpp | 35 +++++++++++--------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/mozilla/netwerk/test/TestFileInput.cpp b/mozilla/netwerk/test/TestFileInput.cpp index d74fea9a3e8..5836cbfdc9b 100644 --- a/mozilla/netwerk/test/TestFileInput.cpp +++ b/mozilla/netwerk/test/TestFileInput.cpp @@ -25,6 +25,7 @@ #include "nsIEventQueueService.h" #include "prinrval.h" #include "prmon.h" +#include "prcmon.h" #include "prio.h" #include "nsIFileStream.h" #include "nsFileSpec.h" @@ -34,21 +35,9 @@ #include "nsITransport.h" #include -#ifdef XP_PC -#define XPCOM_DLL "xpcom32.dll" -#define NETLIB_DLL "netwerk.dll" -#else -#ifdef XP_MAC -#include "nsMacRepository.h" -#else -#define XPCOM_DLL "libxpcom.so" -#define NETLIB_DLL "libnetwerk.so" -#endif -#endif - static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); -static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUE_CID); +static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); PRIntervalTime gDuration = 0; PRUint32 gVolume = 0; @@ -62,17 +51,16 @@ public: if (!mMonitor) return NS_ERROR_OUT_OF_MEMORY; PR_EnterMonitor(mMonitor); - if (mEventQueue == nsnull) + if (mEventQueue == nsnull) PR_CWait(this, PR_INTERVAL_NO_TIMEOUT); + PR_ExitMonitor(mMonitor); printf("running\n"); - // event loop mEventQueue->EventLoop(); while (PR_TRUE) { - } printf("quitting\n"); return NS_OK; @@ -100,8 +88,13 @@ public: PR_EnterMonitor(mMonitor); NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueServiceCID, &rv); if (NS_SUCCEEDED(rv)) { + rv = eventQService->CreateThreadEventQueue(); + + if (NS_FAILED(rv)) return rv; + rv = eventQService->GetThreadEventQueue(PR_CurrentThread(), &mEventQueue); } + if (NS_FAILED(rv)) return rv; // wake up event loop @@ -295,7 +288,7 @@ SerialReadTest(char* dirName) PRUint32 threadCount; rv = threads->Count(&threadCount); for (PRUint32 i = 0; i < threadCount; i++) { - nsIThread* thread = (nsIThread*)(*threads)[i]; + nsIThread* thread = (nsIThread*)threads->ElementAt(i); thread->Join(); NS_RELEASE(thread); } @@ -328,7 +321,9 @@ ParallelReadTest(char* dirName, nsIFileTransportService* fts) NS_ADDREF(reader); nsIThread* readerThread; + rv = NS_NewThread(&readerThread, reader); + NS_ASSERTION(NS_SUCCEEDED(rv), "new thread failed"); rv = reader->Init(readerThread); @@ -357,7 +352,7 @@ ParallelReadTest(char* dirName, nsIFileTransportService* fts) PRUint32 threadCount; rv = threads->Count(&threadCount); for (PRUint32 i = 0; i < threadCount; i++) { - nsIThread* thread = (nsIThread*)(*threads)[i]; + nsIThread* thread = (nsIThread*)threads->ElementAt(i); thread->Join(); NS_RELEASE(thread); } @@ -379,15 +374,15 @@ main(int argc, char* argv[]) char* dirName = argv[1]; // XXX why do I have to do this?! - nsComponentManager::RegisterComponent(kFileTransportServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, "components"); if (NS_FAILED(rv)) return rv; NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; + SerialReadTest(dirName); + ParallelReadTest(dirName, fts); fts->ProcessPendingRequests();