--- gvpe/src/iom.C 2004/11/14 22:47:00 1.25 +++ gvpe/src/iom.C 2005/01/10 19:21:07 1.28 @@ -35,7 +35,7 @@ // for IOM_SIG #if IOM_SIG -# include +# include # include #endif @@ -96,12 +96,17 @@ tstamp NOW; #if IOM_TIME -inline void set_now (void) +tstamp io_manager::now () { struct timeval tv; gettimeofday (&tv, 0); - NOW = (tstamp)tv.tv_sec + (tstamp)tv.tv_usec / 1000000.; + return (tstamp)tv.tv_sec + (tstamp)tv.tv_usec / 1000000.; +} + +void io_manager::set_now () +{ + NOW = now (); } #endif @@ -120,14 +125,14 @@ abort (); } - fcntl (sigpipe[0], F_SETFL, O_NONBLOCK); - fcntl (sigpipe[1], F_SETFL, O_NONBLOCK); + fcntl (sigpipe[0], F_SETFL, O_NONBLOCK); fcntl (sigpipe[0], F_SETFD, FD_CLOEXEC); + fcntl (sigpipe[1], F_SETFL, O_NONBLOCK); fcntl (sigpipe[1], F_SETFD, FD_CLOEXEC); #endif iom_valid = true; #if IOM_TIME - set_now (); + io_manager::set_now (); tw0.start (TSTAMP_MAX); #endif @@ -411,13 +416,14 @@ iow.erase_unordered (i); else { - short revents = iow[i]->events; + io_watcher &w = *iow[i]; + short revents = w.events; - if (!FD_ISSET (iow[i]->fd, &rfd)) revents &= ~EVENT_READ; - if (!FD_ISSET (iow[i]->fd, &wfd)) revents &= ~EVENT_WRITE; + if (!FD_ISSET (w.fd, &rfd)) revents &= ~EVENT_READ; + if (!FD_ISSET (w.fd, &wfd)) revents &= ~EVENT_WRITE; if (revents) - iow[i]->call (*iow[i], revents); + w.call (w, revents); } #endif }