Kernel.sleep() is not monotonic when system clock changes during sleeping
-------------------------------------------------------------------------

                 Key: JRUBY-6236
                 URL: https://jira.codehaus.org/browse/JRUBY-6236
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
         Environment: CentOS 5.6
            Reporter: Yamada Goro


Changing system clock to past time during sleeping results in additional sleep 
time.

For example, call sleep(10), set system clock 10 seconds ago, then sleep() 
takes 20 seconds.

This seems to be caused by the code below. It uses System.currentTimeMillis() 
to determine how long to sleep. 

{code:title=RubyKernel.sleep()|borderStyle=solid}
// Spurious wakeup-loop
do {
    long loopStartTime = System.currentTimeMillis();
    try {
        // We break if we know this sleep was explicitly woken up/interrupted
        if (!rubyThread.sleep(milliseconds)) break;
    } catch (InterruptedException iExcptn) {
    }
    milliseconds -= (System.currentTimeMillis() - loopStartTime);
} while (milliseconds > 0);
{code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to