Subject: Re: wsevent cleanup
To: Martin Husemann <martin@duskware.de>
From: Julio M. Merino Vidal <jmmv84@gmail.com>
List: tech-kern
Date: 02/06/2006 14:20:01
El 06/02/2006, a las 13:59, Martin Husemann escribi=F3:
> On Mon, Feb 06, 2006 at 01:31:00PM +0100, Julio M. Merino Vidal wrote:
>> I didn't do this because, some times, you want to inject more than =20=
>> one
>> event at once (strictly speaking, only the code I added yesterday has
>> this behavior... but am now thinking that the event processing =20
>> code in
>> wsmouse could also use this to do everything atomically). In such =20=
>> case,
>> you'd be checking first if there is room for two elements and =20
>> then, each
>> inject could redo the check to see if there is room for one element.
>
> Well, that sounds ok to me (we are talking about mouse/keyboard events
> here, not network packets - so duplicating a simple check now and then
> is not that bad).
>
> But the obvious other solution (no idea how handy that gets for the =20=
> callers
> you have in mind): allow multiple events being passed to the =20
> _inject function
> in a single call.
This is a good idea too, and it may be better for what I have in mind
because I'd locally construct all the events and then simply call
the function to add them at once. Something like:
struct wscons_event evt[N];
... fill evt with up to N events ... (see below)
error =3D wsevent_inject(evar, evt, N);
if (error !=3D 0)
queue is full
But this makes me think how to deal with the timestamps attached to
the events. The first possibility is to generate them while
constructing each event. In this case, I'd add an extra function
wscons_event_init(*event, type, value) so that the timestamps were
hidden from the caller.
The other possibility is to leave the timestamp initialization to
wsevent_inject, which could then mark all events with the same
timestamp. They happen so close in time that it couldn't make a
difference, could it?
Cheers,
PS: Isn't 'wsevent' a misfortunate name for a queue? It makes me
think of a single event rather than a set of them. Specially
confusing: wsevent_init vs. wscons_event_init.
--=20
Julio M. Merino Vidal <jmmv84@gmail.com>
The Julipedia - http://julipedia.blogspot.com/