Thanks Chris,
You are right, it's simple and works a lot better using your own event queue
when you send lots of events out. Also other "problems" are gone. For people
that are interested, this is how I did it:
#define MAX_EQ_ENTRIES 100
userEventStruct userEventQueue[MAX_EQ_ENTRIES];
unsigned int eventsInUserEventQueue = 0;
unsigned int userEventQueueReadPointer = 0;
unsigned int userEventQueueWritePointer = 0;
//Read events from userEventQueue, and returns number of events read.
unsigned int UserEventQueueRead(userEventStruct * userEvent)
{
if (eventsInUserEventQueue)
{
* userEvent = userEventQueue[userEventQueueReadPointer];
if (++userEventQueueReadPointer == MAX_EQ_ENTRIES)
{
userEventQueueReadPointer = 0;
}
eventsInUserEventQueue--;
return 1;
}
return 0;
}
// Writes new event in the userEventQueue, and returns number of events
written.
unsigned int UserEventQueueWrite(userEventStruct userEvent)
{
//when still available locations in event queue, write the event
if (eventsInUserEventQueue < MAX_EQ_ENTRIES)
{
userEventQueue[userEventQueueWritePointer] = userEvent;
if (++userEventQueueWritePointer == MAX_EQ_ENTRIES)
{
userEventQueueWritePointer = 0;
}
eventsInUserEventQueue++;
return 1;
}
return 0;
}
Regards
Gert
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Chris
Tutty
Sent: Friday, 29 October 2004 15:06
To: Palm Developer Forum
Subject: Re: Event queue size/monitor
From: "Gert van Kruiningen" <[EMAIL PROTECTED]>
> Events are sent by the "serial read function" to the active
> window to inform it about certain data that has arrived and
(snip)
> My problem is that sometimes, the event queue overflows.
>
The Palm OS event queue is quite shallow, fine for the purpose
it was designed for, but not for heavy use of custom events
for notifying background activity. You should also be aware
that any Palm OS dialog (keyboard, alert, etc) will consume
custom events, breaking your communication between the
background process and the interface.
I've found it far better to either use a different notification
mechanism (write the data to a database and display to the
screen from the database, deleting the records as they're
displayed?) or to build your own event handler. It's really
not that much code - a fixed array, a function to add events
and a function to check for events. You can re-use the Palm ]
OS event structures for simplicity or define your own structures.
Although it's a chunk of work, you walk away from a number
of problems associated with the Palm OS event handler and
background processes.
Chris Tutty
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/