--- Glib-Event/Event.xs 2005/11/27 14:02:23 1.1 +++ Glib-Event/Event.xs 2005/11/29 16:03:24 1.3 @@ -21,12 +21,6 @@ }; static void -event_timer_cb (pe_event *pe) -{ - *(int *)(pe->up->ext_data) = -1; -} - -static void event_io_cb (pe_event *pe) { U16 got = ((pe_ioevent *)pe)->got; @@ -39,7 +33,7 @@ ); if (i->pfd->revents) - *(i->got_events)++; + (*(i->got_events))++; } static gint @@ -50,8 +44,7 @@ // tell me your compiler vendor was too incompetent to implement // the C standard within the last six years. struct info info[nfds]; - pe_timer *w_timeout = 0; - int got_events = 0, got_timeout = 0; + int got_events = 0; int n; for (n = 0; n < nfds; n++) @@ -59,6 +52,7 @@ GPollFD *pfd = fds + n; struct info *i = info + n; + i->pfd = pfd; i->got_events = &got_events; pe_io *w = i->w = GEventAPI->new_io (0, 0); @@ -73,31 +67,20 @@ GEventAPI->start ((pe_watcher *)w, 0); } - if (timeout >= 0) - { - w_timeout = GEventAPI->new_timer (0, 0); - w_timeout->base.callback = (void *)event_timer_cb; - w_timeout->base.ext_data = (void *)&got_timeout; - w_timeout->tm.at = GEventAPI->NVtime () + timeout * 0.001; - } - do { PUSHMARK (SP); + XPUSHs (sv_2mortal (newSVnv (timeout >= 0 ? timeout * 0.001 : 86400. * 365.))); + PUTBACK; call_pv ("Event::one_event", G_DISCARD | G_EVAL); - } while (!got_events && !got_timeout); - - if (w_timeout) - GEventAPI->cancel ((pe_watcher *)w_timeout); + SPAGAIN; + } while (timeout < 0 && !got_events); for (n = 0; n < nfds; n++) GEventAPI->cancel ((pe_watcher *)info[n].w); - if (SvOK (ERRSV)) + if (SvTRUE (ERRSV)) croak (0); - if (got_timeout) - return 0; - return got_events; }