This commit is contained in:
dougt%netscape.com 2000-01-06 19:46:44 +00:00
Родитель de6ee4de98
Коммит d186802516
6 изменённых файлов: 45 добавлений и 16 удалений

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

@ -22,6 +22,9 @@
#include "nsCOMPtr.h"
#include "nsEventQueue.h"
#include "nsIEventQueueService.h"
#include "nsIThread.h"
#include "nsIServiceManager.h"
#include "nsIObserverService.h"
#include "nsString2.h"
@ -72,6 +75,31 @@ nsEventQueueImpl::Init()
return NS_OK;
}
NS_IMETHODIMP
nsEventQueueImpl::InitFromPRThread(PRThread* thread)
{
if (thread == NS_CURRENT_THREAD)
{
thread = PR_GetCurrentThread();
}
else if (thread == NS_UI_THREAD)
{
nsCOMPtr<nsIThread> mainIThread;
nsresult rv;
// Get the primordial thread
rv = nsIThread::GetMainThread(getter_AddRefs(mainIThread));
if (NS_FAILED(rv)) return rv;
rv = mainIThread->GetPRThread(&thread);
if (NS_FAILED(rv)) return rv;
}
mEventQueue = PL_CreateNativeEventQueue("Thread event queue...", thread);
NotifyObservers(gActivatedNotification);
return NS_OK;
}
NS_IMETHODIMP
nsEventQueueImpl::InitFromPLQueue(PLEventQueue* aQueue)
{

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

@ -51,6 +51,7 @@ public:
NS_IMETHOD_(PRInt32) GetEventQueueSelectFD();
NS_IMETHOD Init();
NS_IMETHOD InitFromPRThread(PRThread* thread);
NS_IMETHOD InitFromPLQueue(PLEventQueue* aQueue);
NS_IMETHOD EnterMonitor();

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

@ -33,11 +33,9 @@ static NS_DEFINE_CID(kEventQueueCID, NS_EVENTQUEUE_CID);
// XXX move to nsID.h or nsHashtable.h? (copied from nsComponentManager.cpp)
class ThreadKey: public nsHashKey {
private:
const PRThread* id;
public:
ThreadKey(const PRThread* aID) {
ThreadKey(PRThread* aID) {
id = aID;
}
@ -56,6 +54,9 @@ public:
nsHashKey *Clone(void) const {
return new ThreadKey(id);
}
PRThread* id;
};
////////////////////////////////////////////////////////////////////////////////
@ -77,7 +78,7 @@ public:
NS_DECL_ISUPPORTS
nsIEventQueue* GetEventQueue(void); // addrefs!
nsresult MakeNewQueue(nsIEventQueue **aQueue);
nsresult MakeNewQueue(PRThread* thread, nsIEventQueue **aQueue);
nsresult AddQueue(void);
void RemoveQueue(nsIEventQueue *aQueue); // queue goes dark, and is released
@ -106,7 +107,7 @@ EventQueueEntry::EventQueueEntry(nsEventQueueServiceImpl *aService, ThreadKey &a
{
NS_INIT_REFCNT();
mService = aService;
MakeNewQueue(&mQueue);
MakeNewQueue(aKey.id, &mQueue);
NS_ASSERTION(mQueue, "EventQueueEntry constructor failed");
if (mService)
mService->AddEventQueueEntry(this);
@ -136,7 +137,7 @@ nsIEventQueue* EventQueueEntry::GetEventQueue(void)
return answer;
}
nsresult EventQueueEntry::MakeNewQueue(nsIEventQueue **aQueue)
nsresult EventQueueEntry::MakeNewQueue(PRThread* thread, nsIEventQueue **aQueue)
{
nsIEventQueue *queue = 0;
nsresult rv;
@ -145,7 +146,7 @@ nsresult EventQueueEntry::MakeNewQueue(nsIEventQueue **aQueue)
NS_GET_IID(nsIEventQueue), (void**) &queue);
if (NS_SUCCEEDED(rv)) {
rv = queue->Init();
rv = queue->InitFromPRThread(thread);
if (NS_FAILED(rv)) {
NS_RELEASE(queue);
queue = 0; // redundant, but makes me feel better
@ -161,7 +162,7 @@ nsresult EventQueueEntry::AddQueue(void)
nsresult rv = NS_ERROR_NOT_INITIALIZED;
if (mQueue) {
rv = MakeNewQueue(&newQueue);
rv = MakeNewQueue(PR_GetCurrentThread(), &newQueue);
// add it to our chain of queues
if (NS_SUCCEEDED(rv)) {
@ -536,7 +537,6 @@ nsEventQueueServiceImpl::ResolveEventQueue(nsIEventQueue* queueOrConstant, nsIEv
return NS_OK;
}
#ifdef XP_MAC
// MAC specific. Will go away someday
// Bwah ha ha h ha ah aha ha ha
@ -566,5 +566,3 @@ NS_IMETHODIMP nsEventQueueServiceImpl::ProcessEvents()
}
#endif
////////////////////////////////////////////////////////////////////////////////

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

@ -68,9 +68,10 @@ public:
NS_IMETHOD PushThreadEventQueue(nsIEventQueue **aNewQueue);
NS_IMETHOD PopThreadEventQueue(nsIEventQueue *aQueue);
#ifdef XP_MAC
NS_IMETHOD ProcessEvents();
#endif // XP_MAC
#endif
private:
NS_IMETHOD CreateEventQueue(PRThread *aThread);

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

@ -58,6 +58,7 @@ public:
NS_IMETHOD_(PRInt32) GetEventQueueSelectFD() = 0;
NS_IMETHOD Init() = 0;
NS_IMETHOD InitFromPRThread(PRThread* thread) = 0;
NS_IMETHOD InitFromPLQueue(PLEventQueue* aQueue) = 0;
NS_IMETHOD EnterMonitor() = 0;

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

@ -72,9 +72,9 @@ public:
NS_IMETHOD ResolveEventQueue(nsIEventQueue* queueOrConstant, nsIEventQueue* *resultQueue) = 0;
#ifdef XP_MAC
// This is ment to be temporary until something better is worked out
NS_IMETHOD ProcessEvents() = 0;
#endif
NS_IMETHOD ProcessEvents() = 0;
#endif
};
#endif /* nsIEventQueueService_h___ */