3 * helpers for event handling
13 static void *toev_callback(oop_source *source, struct timeval tv, void *t_v) {
14 TimeoutEvent *toev= t_v;
20 void toev_init(TimeoutEvent *toev) { toev->running= 0; }
22 void toev_start(TimeoutEvent *toev) {
24 if (toev->duration==-1) return;
26 mgettimeofday(&toev->abs);
27 assert(toev->duration < INT_MAX/1000);
28 toev->abs.tv_usec += toev->duration * 1000;
29 toev->abs.tv_sec += toev->abs.tv_usec / 1000000;
30 toev->abs.tv_usec %= 1000000;
31 events->on_time(events, toev->abs, toev_callback, toev);
34 void toev_stop(TimeoutEvent *toev) {
35 if (!toev->running) return;
37 events->cancel_time(events, toev->abs, toev_callback, toev);