Changeset 11969


Ignore:
Timestamp:
05/31/09 15:19:00 (12 years ago)
Author:
ehuelsmann
Message:

Factor out the lisp->Java sleep interval conversion routine.
Also clarify the code by using a type assertion instead of a
direct class cast.

Requested by tcr (from #lisp) for his work on SLIME & ABCL.

File:
1 edited

Legend:

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

    r11967 r11969  
    10631063    };
    10641064
     1065    public static final long javaSleepInterval(LispObject lispSleep)
     1066            throws ConditionThrowable
     1067    {
     1068        double d =
     1069            checkDoubleFloat(lispSleep.multiplyBy(new DoubleFloat(1000))).getValue();
     1070        if (d < 0)
     1071            type_error(lispSleep, list(Symbol.REAL, Fixnum.ZERO));
     1072
     1073        return (d < Long.MAX_VALUE ? (long) d : Long.MAX_VALUE);
     1074    }
     1075
    10651076    // ### sleep
    10661077    private static final Primitive SLEEP = new Primitive("sleep", "seconds")
     
    10691080        public LispObject execute(LispObject arg) throws ConditionThrowable
    10701081        {
    1071             double d =
    1072                 ((DoubleFloat)arg.multiplyBy(new DoubleFloat(1000))).getValue();
    1073             if (d < 0)
    1074                 return type_error(arg, list(Symbol.REAL, Fixnum.ZERO));
    1075             long millis = d < Long.MAX_VALUE ? (long) d : Long.MAX_VALUE;
     1082
    10761083            try {
    1077                 Thread.sleep(millis);
     1084                Thread.sleep(javaSleepInterval(arg));
    10781085            }
    10791086            catch (InterruptedException e) {
Note: See TracChangeset for help on using the changeset viewer.