summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcls%seawood.org <devnull@localhost>1999-09-21 19:43:23 +0000
committercls%seawood.org <devnull@localhost>1999-09-21 19:43:23 +0000
commitbb265e0d97c4d8a1742613a310563cce504d8bdf (patch)
tree178a5f9ee0b57f21baf931b1ce4337269a3519ca
parent85669fa9e577c1ada07daea800b1bcf3e7fc4cc5 (diff)
downloadnspr-hg-unlabeled-3.19.8.tar.gz
Sync'd with the HEAD branch again.unlabeled-3.19.8
-rw-r--r--lib/ds/plevent.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/lib/ds/plevent.c b/lib/ds/plevent.c
index e696e8ce..e337d7fb 100644
--- a/lib/ds/plevent.c
+++ b/lib/ds/plevent.c
@@ -338,7 +338,9 @@ PL_GetEvent(PLEventQueue* self)
return NULL;
mon = self->monitor;
- PR_EnterMonitor(mon);
+ if (mon) {
+ PR_EnterMonitor(mon);
+ }
if ( self->type == EventQueueIsNative )
err = _pl_AcknowledgeNativeNotify(self);
@@ -352,7 +354,9 @@ PL_GetEvent(PLEventQueue* self)
}
done:
- PR_ExitMonitor(mon);
+ if (mon) {
+ PR_ExitMonitor(mon);
+ }
return event;
}
@@ -462,6 +466,7 @@ PL_ProcessPendingEvents(PLEventQueue* self)
if (PR_FALSE != self->processingEvents) return;
self->processingEvents = PR_TRUE;
+#if !defined(WIN32)
while (PR_TRUE) {
PLEvent* event = PL_GetEvent(self);
if (event == NULL) break;
@@ -470,6 +475,33 @@ PL_ProcessPendingEvents(PLEventQueue* self)
PL_HandleEvent(event);
PR_LOG(event_lm, PR_LOG_DEBUG, ("$$$ done processing event"));
}
+#else
+ /* Only process the events that are already in the queue, and
+ * not any new events that get added. Do this by making a copy of
+ * the queue
+ */
+ PR_EnterMonitor(self->monitor);
+ if (PR_CLIST_IS_EMPTY(&self->queue)) {
+ PR_ExitMonitor(self->monitor);
+ } else {
+ struct PLEventQueue tmpQueue;
+ /* Copy the events to a temporary queue */
+ memcpy(&tmpQueue, self, sizeof(tmpQueue));
+ tmpQueue.queue.next->prev = &tmpQueue.queue;
+ tmpQueue.queue.prev->next = &tmpQueue.queue;
+ tmpQueue.monitor = 0; /* don't waste time locking this queue when getting events */
+ PR_INIT_CLIST(&self->queue);
+ PR_ExitMonitor(self->monitor);
+ /* Now process the existing events */
+ while (PR_TRUE) {
+ PLEvent* event = PL_GetEvent(&tmpQueue);
+ if (event == NULL) break;
+ PR_LOG(event_lm, PR_LOG_DEBUG, ("$$$ processing event"));
+ PL_HandleEvent(event);
+ PR_LOG(event_lm, PR_LOG_DEBUG, ("$$$ done processing event"));
+ }
+ }
+#endif
self->processingEvents = PR_FALSE;
}