Re: [AD] review timed-wait changes |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Mon, Apr 7, 2008 at 2:29 PM, David Capello <davidcapello@xxxxxxxxxx> wrote:
> Hi Peter
>
> 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();
}
For relative we could double up the api with al_wait_XXX_for and
al_wait_XXX_until or use macros to convert relative to absolute (we do
use BPS_TO_TIMER etc in Allegro4 now)
Pete