lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Mon, Nov 14, 2011 at 8:31 PM, Stefan Reich
<> wrote:
> Yeah, actually I just found the step function in Iup. Minutes after
> typing the mail...
> OK, so calling the step functions with some small sleep inbetween
> (100ms or some such) might basically do the trick. I'll do some more
> experimentation and report how it works.

This may work for. Sometimes it's the only way depending on underlying
Although really good practice usually looks like following (this is an
abstract of course):

Display *dpy = open_and_do_some_stuff ();
int display_fd = ConnectionNumber (dpy);
someconnection_t *connection = open_connection ();
int socket_fd = someconnection_get_socket_fd (connection);

fd_set read_fdset;
FD_ZERO (&read_fdset);
FD_ZERO (&write_fdset);
FD_SET (display_fd, &read_fdset);
FD_SET (socket_fd, &read_fdset);
int fd_top = MAX (socket_fd, display_fd) + 1;

int ret;
while ((ret = pselect (fd_top, &read_fdset, NULL, NULL, &some_timeout,
NULL)) != 0) {
    if (ret == -1) {
        /* Handle error */
    if (ret > 0) {
        /* Got input from X-server or from network socket */
    /* We may do some periodical work here */

We've got no user input or network delay here and still our process
don't eat CPU time.
This works fine with X-server. But I don't know much about other systems.