Re: [AD] review timed-wait changes

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


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);




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