Notifier question

weiser.pa at xerox.com weiser.pa at xerox.com
Thu Jun 8 11:10:42 AEST 1989


It is a frequent question: "How do I "poll" the nofier while I am in a
tight processing loop?" Calling "notify_dispatch()" in the loop does not
work.  I use the following routine to force the poll, called
"window_update".  Its a kludge, but it works, because the notifier has to
take control around I/O calls, so this gets it a chance to get in and
handle some buttons, screen refreshes, signals, whatever.  Stick a call to
"window_update()" in your tight loop... (but not too often: "select" is
expensive.)

window_update()
{
  int width = 0;
  fd_set  readfds, writefds, exceptfds;
  struct timeval real_timeout;
  FD_ZERO(&writefds);
  FD_ZERO(&readfds);
  FD_ZERO(&exceptfds);
  real_timeout.tv_sec = 0;
  real_timeout.tv_usec = 0;
  select(width, &readfds, &writefds, &exceptfds, &real_timeout);
}



More information about the Comp.sys.sun mailing list