Home Overview FAQ Documentation Download Mailing List Geomview For Windows? Support Users Development Bug Reporting Contributing Contact Us Sponsors
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Checking for multiple input sources in FORMS
I'd like to suggest a change to loops that look like: while (1) { if (async_fnextc(stdin, 0) != NODATA) { obj = LSexpr(lake); LEval(obj); } fl_check_forms(); } The problem is that, if nothing interesting is happening, this loop will keep grinding along soaking up CPU cycles. Anything else running on the same machine -- e.g. geomview -- will be noticeably slower. The simplest kind of change is just to add a fixed short delay to the loop, or at least one that's exercised if there's nothing happening. sginap() will do this but it's naturally SGI specific. To write portable code dealing with short time delays, you're stuck with select(), but it's fairly tame in this application: #include <sys/time.h> /* for declaration of "struct timeval" */ ... while (1) { if (async_fnextc(stdin, 0) != NODATA) { obj = LSexpr(lake); LEval(obj); } else { static struct timeval tenth = { 0, 100000 }; /* 0.1 sec */ select(0, NULL, NULL, NULL, &tenth); } fl_check_forms(); } [You could do a bit better by telling select() about the file descriptors you really care about, but it's probably not worth the bother here.]
|
||
Home | Overview | FAQ | Documentation | Support | Download | Mailing List Windows? | Development | Bug Reporting | Contributing | Contact Us | Sponsors |
|||
site hosted by |