Quoteing navindra / cs.mcgill.ca, on Fri, Feb 18, 2005 at 12:33:13PM +0900:
> Sam Roberts <sroberts / uniserve.com> wrote:
> > Can anybody give me any hints as to what I should be looking for? What
> > can cause sleep(0) to wake up?
> 
> The documentation is wrong. 
> 
> sleep(0) returns immediately.  sleep with *zero* arguments sleeps
> forever.

Thank you, thank you, thank you!

I had started to notice that sometimes the code busy loops, and
sometimes it doesn't, it doesn't matter whether I make any code changes,
that turned out to be unrelated.

Do you have any idea why this should be? What does Kernel.sleep(0)
actually do?

Sam

> 
> static VALUE
> rb_f_sleep(argc, argv)
>     int argc;
>     VALUE *argv;
> {
>     int beg, end;
> 
>     beg = time(0);
>     if (argc == 0) {
>         rb_thread_sleep_forever();
>     }
>     else if (argc == 1) {
>         rb_thread_wait_for(rb_time_interval(argv[0]));
>     }
>     else {
>         rb_raise(rb_eArgError, "wrong number of arguments");
>     }
> 
>     end = time(0) - beg;
> 
>     return INT2FIX(end);
> }
> 
> Cheers,
> Navin.
>