in reply to I want to forfeit my timeshare

So is there an easy solution? Is there a solution at all?

Check out the four-argument form of select. The forth argument specifies the amount of time to sleep. You can specify fractional seconds.

Replies are listed 'Best First'.
Re: Re: I want to forfeit my timeshare
by jepri (Parson) on Aug 24, 2001 at 10:33 UTC
    Regardless of the fraction of a second I can sleep, I'm still locking myself to n checks per second. I want to check once each time I get a time slice, but every time I get a time slice. If I limit myself to every tenth of a second, when the program runs a 100 Ghz machine it will still only check ten times per second.

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.

      Not true; select will wake your process if there are any pending filehandle events (read/write/error), before the timelimit is up. The argument is simply a timeout, after which control is returned to your program, assuming no events occur.

      If your problem with select is that it doesn't allow you to wait on the other types of events, then it would help if you mentioned exactly what sorts of events you're catching. In the meantime, I'd suggest looking at Event (or POE, which I don't particularly like).

         MeowChow                                   
                     s aamecha.s a..a\u$&owag.print
      Sleep (0) is the answer, because it is not optimized away. (and since sleep is implemented using select...).

      T I M T O W T D I