Changed the arguments to PostSynchronousEvent. Added an EventLoop method.

This commit is contained in:
hyatt%netscape.com 1999-05-05 23:55:10 +00:00
Родитель 777eac9864
Коммит b787455ad9
6 изменённых файлов: 28 добавлений и 168 удалений

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

@ -1,53 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsIEventQueue_h__
#define nsIEventQueue_h__
#include "nsISupports.h"
#include "prthread.h"
#include "plevent.h"
// {176AFB41-00A4-11d3-9F2A-00400553EEF0}
#define NS_IEVENTQUEUE_IID \
{ 0x176afb41, 0xa4, 0x11d3, { 0x9f, 0x2a, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
// {13D86C61-00A9-11d3-9F2A-00400553EEF0}
#define NS_EVENTQUEUE_CID \
{ 0x13d86c61, 0xa9, 0x11d3, { 0x9f, 0x2a, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
class nsIEventQueue : public nsISupports
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IEVENTQUEUE_IID; return iid;}
NS_IMETHOD_(PRStatus) PostEvent(PLEvent* aEvent) = 0;
NS_IMETHOD PostSynchronousEvent(PLEvent* aEvent) = 0;
NS_IMETHOD ProcessPendingEvents() = 0;
NS_IMETHOD EventAvailable(PRBool& aResult) = 0;
NS_IMETHOD GetEvent(PLEvent** aResult) = 0;
NS_IMETHOD_(PRInt32) GetEventQueueSelectFD() = 0;
NS_IMETHOD Init() = 0;
NS_IMETHOD InitFromPLQueue(PLEventQueue* aQueue) = 0;
};
#endif /* nsIEventQueue_h___ */

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

@ -1,106 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#include "nsEventQueue.h"
nsEventQueueImpl::nsEventQueueImpl()
{
NS_INIT_REFCNT();
mEventQueue = NULL;
}
nsEventQueueImpl::~nsEventQueueImpl()
{
if (NULL != mEventQueue) {
PL_DestroyEventQueue(mEventQueue);
}
}
NS_IMETHODIMP
nsEventQueueImpl::Init()
{
mEventQueue = PL_CreateNativeEventQueue("Thread event queue...", PR_GetCurrentThread());
return NS_OK;
}
NS_IMETHODIMP
nsEventQueueImpl::InitFromPLQueue(PLEventQueue* aQueue)
{
mEventQueue = aQueue;
return NS_OK;
}
/* nsISupports interface implementation... */
NS_IMPL_ISUPPORTS(nsEventQueueImpl,kIEventQueueIID);
/* nsIEventQueue interface implementation... */
NS_IMETHODIMP_(PRStatus)
nsEventQueueImpl::PostEvent(PLEvent* aEvent)
{
return PL_PostEvent(mEventQueue, aEvent);
}
NS_IMETHODIMP
nsEventQueueImpl::PostSynchronousEvent(PLEvent* aEvent)
{
PL_PostSynchronousEvent(mEventQueue, aEvent);
return NS_OK;
}
NS_IMETHODIMP
nsEventQueueImpl::ProcessPendingEvents()
{
PL_ProcessPendingEvents(mEventQueue);
return NS_OK;
}
NS_IMETHODIMP
nsEventQueueImpl::EventAvailable(PRBool& aResult)
{
aResult = PL_EventAvailable(mEventQueue);
return NS_OK;
}
NS_IMETHODIMP
nsEventQueueImpl::GetEvent(PLEvent** aResult)
{
*aResult = PL_GetEvent(mEventQueue);
return NS_OK;
}
NS_IMETHODIMP_(PRInt32)
nsEventQueueImpl::GetEventQueueSelectFD()
{
return PL_GetEventQueueSelectFD(mEventQueue);
}
NS_METHOD
nsEventQueueImpl::Create(nsISupports *aOuter,
REFNSIID aIID,
void **aResult)
{
nsEventQueueImpl* evt = new nsEventQueueImpl();
if (evt == NULL)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = evt->QueryInterface(aIID, aResult);
return rv;
}

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

@ -33,9 +33,12 @@ public:
// nsIEventQueue interface...
NS_IMETHOD_(PRStatus) PostEvent(PLEvent* aEvent);
NS_IMETHOD PostSynchronousEvent(PLEvent* aEvent);
NS_IMETHOD PostSynchronousEvent(PLEvent* aEvent, void** aResult);
NS_IMETHOD ProcessPendingEvents();
NS_IMETHOD EventAvailable(PRBool& aResult);
NS_IMETHOD EventLoop();
NS_IMETHOD EventAvailable(PRBool& aResult);
NS_IMETHOD GetEvent(PLEvent** aResult);
NS_IMETHOD_(PRInt32) GetEventQueueSelectFD();

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

@ -60,10 +60,14 @@ nsEventQueueImpl::PostEvent(PLEvent* aEvent)
}
NS_IMETHODIMP
nsEventQueueImpl::PostSynchronousEvent(PLEvent* aEvent)
nsEventQueueImpl::PostSynchronousEvent(PLEvent* aEvent, void** aResult)
{
PL_PostSynchronousEvent(mEventQueue, aEvent);
return NS_OK;
void* result = PL_PostSynchronousEvent(mEventQueue, aEvent);
if (aResult)
{
*aResult = result;
}
return NS_OK;
}
NS_IMETHODIMP
@ -73,6 +77,13 @@ nsEventQueueImpl::ProcessPendingEvents()
return NS_OK;
}
NS_IMETHODIMP
nsEventQueueImpl::EventLoop()
{
PL_EventLoop(mEventQueue);
return NS_OK;
}
NS_IMETHODIMP
nsEventQueueImpl::EventAvailable(PRBool& aResult)
{

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

@ -33,9 +33,12 @@ public:
// nsIEventQueue interface...
NS_IMETHOD_(PRStatus) PostEvent(PLEvent* aEvent);
NS_IMETHOD PostSynchronousEvent(PLEvent* aEvent);
NS_IMETHOD PostSynchronousEvent(PLEvent* aEvent, void** aResult);
NS_IMETHOD ProcessPendingEvents();
NS_IMETHOD EventAvailable(PRBool& aResult);
NS_IMETHOD EventLoop();
NS_IMETHOD EventAvailable(PRBool& aResult);
NS_IMETHOD GetEvent(PLEvent** aResult);
NS_IMETHOD_(PRInt32) GetEventQueueSelectFD();

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

@ -38,8 +38,10 @@ public:
static const nsIID& GetIID() { static nsIID iid = NS_IEVENTQUEUE_IID; return iid;}
NS_IMETHOD_(PRStatus) PostEvent(PLEvent* aEvent) = 0;
NS_IMETHOD PostSynchronousEvent(PLEvent* aEvent) = 0;
NS_IMETHOD ProcessPendingEvents() = 0;
NS_IMETHOD PostSynchronousEvent(PLEvent* aEvent, void** aResult) = 0;
NS_IMETHOD ProcessPendingEvents() = 0;
NS_IMETHOD EventLoop() = 0;
NS_IMETHOD EventAvailable(PRBool& aResult) = 0;
NS_IMETHOD GetEvent(PLEvent** aResult) = 0;