Changeset 14679


Ignore:
Timestamp:
04/17/14 11:29:33 (4 years ago)
Author:
mevenson
Message:

Non-zero timeouts CL:SLEEP and THREADS:OBJECT-WAIT below the timer Planck limit interpolated as a nanosecond.

Thanks for James Lawrence for the consul.

Addresses #14632.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/LispThread.java

    r14632 r14679  
    12651265      + "SECONDS may be specified as a fraction of a second, with intervals\n"
    12661266      + "less than or equal to a nanosecond resulting in a yield of execution\n"
    1267       + "to other waiting threads rather than an actual sleep.")
     1267      + "to other waiting threads rather than an actual sleep.\n"
     1268      + "A zero value of SECONDS *may* result in the JVM sleeping indefinitely,\n"
     1269      + "depending on the implementation.")
    12681270    private static final Primitive SLEEP = new Primitive("sleep", PACKAGE_CL, true)
    12691271    {
     
    12731275          long millis = sleepMillisPart(arg);
    12741276          int nanos = sleepNanosPart(arg);
     1277          boolean zeroArgP = arg.ZEROP() != NIL;
    12751278
    12761279          try {
    12771280            if (millis == 0 && nanos == 0) {
    1278               Thread.yield();
     1281              if (zeroArgP) {
     1282                Thread.sleep(0, 0);
     1283              } else {
     1284                Thread.sleep(0, 1);
     1285              }
    12791286            } else {
    12801287              Thread.sleep(millis, nanos);
     
    14411448       + "Optionally unblock execution after TIMEOUT seconds.  A TIMEOUT of zero\n"
    14421449       + "means to wait indefinitely.\n"
     1450       + "A non-zero TIMEOUT of less than a nanosecond is interpolated as a nanosecond wait."
    14431451       + "\n"
    14441452       + "See the documentation of java.lang.Object.wait() for further\n"
     
    14681476
    14691477        {
     1478          long millis = sleepMillisPart(timeout);
     1479          int nanos = sleepNanosPart(timeout);
     1480          boolean zeroArgP = timeout.ZEROP() != NIL;
     1481         
    14701482            try {
    1471         object.lockableInstance().wait(sleepMillisPart(timeout),
    1472                sleepNanosPart(timeout));
     1483              if (millis == 0 && nanos == 0) {
     1484                if (zeroArgP) {
     1485                  object.lockableInstance().wait(0, 0);
     1486                } else {
     1487                  object.lockableInstance().wait(0, 1);
     1488                }
     1489              } else {
     1490                object.lockableInstance().wait(millis, nanos);
     1491              }
    14731492            }
    14741493            catch (InterruptedException e) {
Note: See TracChangeset for help on using the changeset viewer.