looking at libevent cvs i see starting at line 562:

               gettime(&now);
                timersub(&ev->ev_timeout, &now, &res);
                /* correctly remap to real time */
                gettimeofday(&now, NULL);
                timeradd(&now, &res, tv);

shouldn't that gettimeofday be a gettime call
for consistency?

and actually, since gettime() is called in every event_add,
and multiple times in every pass through event_base_loop,
i might like to override it from outside, in case i've got
my own implementation
(with a user-space clock).
that would mean changing event.c to something like:

int (*event_gettime)(struct timeval *);

...
static int
gettime(struct timeval *tp)
{
   if (event_gettime != 0) return (*event_gettime)(tp);

...

void *
event_init(void)
{
   event_gettime = 0;
...

But also it doesn't seem necessary to call gettime 3 times
through every pass. It currently does it twice before
dispatch and once afterwards.
I believe this can be reduced.
the extra call to gettime in timeout_next() seems
unnecessary since event_base_loop just did it.
As for the call in timeout_process, i don't see why
it needs to do any processing at all unless the
dispatch call timed out, and regardless, some dispatch
drivers on some operating systems will update the tv
anyway to indicate how much time was taken.

-mda
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users

Reply via email to