--- gvpe/src/iom.C 2004/01/17 01:18:36 1.13 +++ gvpe/src/iom.C 2004/01/29 23:17:39 1.17 @@ -21,14 +21,40 @@ #include #include -#include #include +#if 1 // older unices need these includes for select(2) +# include +# include +#endif + +// if the BSDs would at least be marginally POSIX-compatible.. *sigh* +// until that happens, sys/select.h must come last +#include + #include "iom.h" // TSTAMP_MAX must still fit into a positive struct timeval #define TSTAMP_MAX (double)(1UL<<31) +// this is a dummy time watcher to ensure that the first +// time watcher is _always_ valid, this gets rid of a lot +// of null-pointer-checks +// (must come _before_ iom is being defined) +static struct tw0 : time_watcher { + void cb (time_watcher &w) + { + // should never get called + // reached end-of-time, or tstamp has a bogus definition, + // or compiler initilization order broken, or somethine else :) + abort (); + } + + tw0() + : time_watcher (this, &tw0::cb) + { } +} tw0; + tstamp NOW; static bool iom_valid; io_manager iom; @@ -41,6 +67,9 @@ if (!w->active) { +#if IOM_CHECK + queue.activity = true; +#endif queue.push_back (w); w->active = queue.size (); } @@ -152,11 +181,20 @@ } #if IOM_CHECK + tw.activity = false; + for (int i = cw.size (); i--; ) if (!cw[i]) cw.erase_unordered (i); else cw[i]->call (*cw[i]); + + if (tw.activity) + { + tval.tv_sec = 0; + tval.tv_usec = 0; + to = &tval; + } #endif #if IOM_IO @@ -224,22 +262,6 @@ } } -// this is a dummy time watcher to ensure that the first -// time watcher is _always_ valid, this gets rid of a lot -// of null-pointer-checks -static struct tw0 : time_watcher { - void cb (time_watcher &w) - { - // should never get called - // reached end-of-time, or tstamp has a bogus definition :) - abort (); - } - - tw0() - : time_watcher (this, &tw0::cb) - { } -} tw0; - io_manager::io_manager () { iom_valid = true;