Re: [AD] review timed-wait changes

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


On Mon, Apr 7, 2008 at 8:35 AM, David Capello <davidcapello@xxxxxxxxxx> wrote:
On Mon, Apr 7, 2008 at 11:48 AM, Peter Hull <peterhull90@xxxxxxxxxx> wrote:
> On Mon, Apr 7, 2008 at 2:29 PM, David Capello <davidcapello@xxxxxxxxxx> wrote:
>  > On Sun, Apr 6, 2008 at 11:42 AM, Peter Wang <novalazy@xxxxxxxxxx> wrote:
> > >  Question: should al_wait_for_event_timed() take an absolute timeout
>  > >  specification, or should we provide both?  Relative timeouts are
>  > >  convenient for one off calls, but absolute timeouts would be much better
>  > >  when waiting for multiple events in a loop, e.g.
>  >
> > Could be convenient, anyway the relative-timeout is the more
>  > common option in all APIs. I think that we should provide both
>  > options. The absolute-timeout routine could be called
>  > al_wait_for_event_until() or something.
>  >
>  I agree there's no compelling reason either way but I think absolute
>  would make more sense, for example you could have this for your fixed
>  frame-rate loop:
>  float abst = al_current_time();
>  while (true) {
>   abst += 1 / frame_rate;
>
>  while (al_wait_for_event_timed(queue, &ev, abst)) {
>    handle ev
>   }
>   /* time's up */
>   update_logic();
>   draw();
>  }

This code looks really good. Now I think that it's better
the absolute version :)

Also, the relative option is really easy to "simulate" with
the absolute one (and no backwards):

 al_wait_for_event_timed(q, &e, al_current_time()+msecs);

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Register now and save $200. Hurry, offer ends at 11:59 p.m.,
Monday, April 7! Use priority code J8TLD2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
--
https://lists.sourceforge.net/lists/listinfo/alleg-developers

The event loop can take TIMER events.  In the case the event queue does become backlogged, you should be able to clear it instantly (compared to the time between timer events).

--ryan


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