… | |
… | |
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) |
… | |
… | |
57 | if (!iom_valid) |
65 | if (!iom_valid) |
58 | abort (); |
66 | abort (); |
59 | |
67 | |
60 | if (!w->active) |
68 | if (!w->active) |
61 | { |
69 | { |
|
|
70 | #if IOM_CHECK |
|
|
71 | queue.activity = true; |
|
|
72 | #endif |
62 | queue.push_back (w); |
73 | queue.push_back (w); |
63 | w->active = queue.size (); |
74 | w->active = queue.size (); |
64 | } |
75 | } |
65 | } |
76 | } |
66 | |
77 | |
… | |
… | |
168 | } |
179 | } |
169 | #endif |
180 | #endif |
170 | } |
181 | } |
171 | |
182 | |
172 | #if IOM_CHECK |
183 | #if IOM_CHECK |
|
|
184 | tw.activity = false; |
|
|
185 | |
173 | for (int i = cw.size (); i--; ) |
186 | for (int i = cw.size (); i--; ) |
174 | if (!cw[i]) |
187 | if (!cw[i]) |
175 | cw.erase_unordered (i); |
188 | cw.erase_unordered (i); |
176 | else |
189 | else |
177 | 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 | } |
178 | #endif |
198 | #endif |
179 | |
199 | |
180 | #if IOM_IO |
200 | #if IOM_IO |
181 | fd_set rfd, wfd, efd; |
201 | fd_set rfd, wfd, efd; |
182 | |
202 | |
… | |
… | |
248 | |
268 | |
249 | #if IOM_TIME |
269 | #if IOM_TIME |
250 | set_now (); |
270 | set_now (); |
251 | |
271 | |
252 | tw0.start (TSTAMP_MAX); |
272 | tw0.start (TSTAMP_MAX); |
253 | printf ("abort, %f but inly on %f\n", NOW, tw0.at); |
|
|
254 | #endif |
273 | #endif |
255 | } |
274 | } |
256 | |
275 | |
257 | io_manager::~io_manager () |
276 | io_manager::~io_manager () |
258 | { |
277 | { |