ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/iom.C
(Generate patch)

Comparing gvpe/src/iom.C (file contents):
Revision 1.13 by pcg, Sat Jan 17 01:18:36 2004 UTC vs.
Revision 1.17 by pcg, Thu Jan 29 23:17:39 2004 UTC

19 19
20#include <cstdio> 20#include <cstdio>
21#include <cstdlib> 21#include <cstdlib>
22#include <cerrno> 22#include <cerrno>
23 23
24#include <sys/time.h>
25
26#if 1 // older unices need these includes for select(2)
27# include <unistd.h>
28# include <sys/types.h>
29#endif
30
31// if the BSDs would at least be marginally POSIX-compatible.. *sigh*
32// until that happens, sys/select.h must come last
24#include <sys/select.h> 33#include <sys/select.h>
25#include <sys/time.h>
26 34
27#include "iom.h" 35#include "iom.h"
28 36
29// TSTAMP_MAX must still fit into a positive struct timeval 37// TSTAMP_MAX must still fit into a positive struct timeval
30#define TSTAMP_MAX (double)(1UL<<31) 38#define TSTAMP_MAX (double)(1UL<<31)
39
40// this is a dummy time watcher to ensure that the first
41// time watcher is _always_ valid, this gets rid of a lot
42// of null-pointer-checks
43// (must come _before_ iom is being defined)
44static struct tw0 : time_watcher {
45 void cb (time_watcher &w)
46 {
47 // should never get called
48 // reached end-of-time, or tstamp has a bogus definition,
49 // or compiler initilization order broken, or somethine else :)
50 abort ();
51 }
52
53 tw0()
54 : time_watcher (this, &tw0::cb)
55 { }
56} tw0;
31 57
32tstamp NOW; 58tstamp NOW;
33static bool iom_valid; 59static bool iom_valid;
34io_manager iom; 60io_manager iom;
35 61
39 if (!iom_valid) 65 if (!iom_valid)
40 abort (); 66 abort ();
41 67
42 if (!w->active) 68 if (!w->active)
43 { 69 {
70#if IOM_CHECK
71 queue.activity = true;
72#endif
44 queue.push_back (w); 73 queue.push_back (w);
45 w->active = queue.size (); 74 w->active = queue.size ();
46 } 75 }
47} 76}
48 77
150 } 179 }
151#endif 180#endif
152 } 181 }
153 182
154#if IOM_CHECK 183#if IOM_CHECK
184 tw.activity = false;
185
155 for (int i = cw.size (); i--; ) 186 for (int i = cw.size (); i--; )
156 if (!cw[i]) 187 if (!cw[i])
157 cw.erase_unordered (i); 188 cw.erase_unordered (i);
158 else 189 else
159 cw[i]->call (*cw[i]); 190 cw[i]->call (*cw[i]);
191
192 if (tw.activity)
193 {
194 tval.tv_sec = 0;
195 tval.tv_usec = 0;
196 to = &tval;
197 }
160#endif 198#endif
161 199
162#if IOM_IO 200#if IOM_IO
163 fd_set rfd, wfd, efd; 201 fd_set rfd, wfd, efd;
164 202
222 break; 260 break;
223#endif 261#endif
224 } 262 }
225} 263}
226 264
227// this is a dummy time watcher to ensure that the first
228// time watcher is _always_ valid, this gets rid of a lot
229// of null-pointer-checks
230static struct tw0 : time_watcher {
231 void cb (time_watcher &w)
232 {
233 // should never get called
234 // reached end-of-time, or tstamp has a bogus definition :)
235 abort ();
236 }
237
238 tw0()
239 : time_watcher (this, &tw0::cb)
240 { }
241} tw0;
242
243io_manager::io_manager () 265io_manager::io_manager ()
244{ 266{
245 iom_valid = true; 267 iom_valid = true;
246 268
247#if IOM_TIME 269#if IOM_TIME

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines