Re: [AD] events.c patch

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


--- On Fri, 10/24/08, Peter Wang <novalazy@xxxxxxxxxx> wrote:

> From: Peter Wang <novalazy@xxxxxxxxxx>
> Subject: Re: [AD] events.c patch
> To: alleg-developers@xxxxxxxxxx
> Date: Friday, October 24, 2008, 12:09 AM
> On 2008-10-23, Paul Suntsov
> <siegelords_abode@xxxxxxxxxx> wrote:
> > Hello,
> > 
> > Attached is a patch that makes uniform the behaviour
> of
> > al_wait_for_event, al_peek_next_event,
> al_get_next_event and the timed
> > versions of the wait one when the second argument is
> 0.
> > 
> > Before, the get/peek versions asserted this away. The
> wait version
> > took the parameter to mean whether it would actually
> do anything to
> > the queue or not, which I thought illogical.
> 
> You can think of the non-NULL form as a convenience.
> 
>     al_wait_for_event(q, NULL)  == block
>     al_wait_for_event(q, event) == block + get
> 
> > The behaviour now is
> > consistent amongst all of them: specifically, if a 0
> is passed as the
> > return event, it is not written to. Otherwise,
> everything happens as
> > normal: events are deleted, or peeked as usual.
> 
> The new behaviour would be redundant:
> 
>     al_get_next_event(q, NULL)  == al_drop_next_event

Not quite, as al_drop_next event does not return a value at this point. If you make al_drop_next_event return a bool like all other queue functions, then I will agree that all of the functionality will be taken care of without altering the current behaviour of the functions in the patch. Without this change, it is not possible to drop an event, and check whether the queue is empty or not without using two functions at once (i.e. al_drop_next_event() followed by a al_event_queue_is_empty()). This is not necessary for all other functions, so there is an inconsistency there.

>     al_peek_next_event(q, NULL) == !al_event_queue_is_empty
> 
> Not sure I see the point.  Moreover, I think it is
> potentially confusing
> as al_wait_for_event(q, NULL) acts like peek, but
> al_get_next_event(q, NULL) acts like drop.
> 
> Peter
> 
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move
> Developer's challenge
> Build the coolest Linux based applications with Moblin SDK
> & win great prizes
> Grand prize is a trip for two to an Open Source event
> anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> -- 
> https://lists.sourceforge.net/lists/listinfo/alleg-developers


      




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/