[armedbear-cvs] r11969 - trunk/abcl/src/org/armedbear/lisp

Erik Huelsmann ehuelsmann at common-lisp.net
Sun May 31 15:19:04 UTC 2009


Author: ehuelsmann
Date: Sun May 31 11:19:00 2009
New Revision: 11969

Log:
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.

Modified:
   trunk/abcl/src/org/armedbear/lisp/LispThread.java

Modified: trunk/abcl/src/org/armedbear/lisp/LispThread.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/LispThread.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/LispThread.java	Sun May 31 11:19:00 2009
@@ -1062,19 +1062,26 @@
         }
     };
 
+    public static final long javaSleepInterval(LispObject lispSleep)
+            throws ConditionThrowable
+    {
+        double d =
+            checkDoubleFloat(lispSleep.multiplyBy(new DoubleFloat(1000))).getValue();
+        if (d < 0)
+            type_error(lispSleep, list(Symbol.REAL, Fixnum.ZERO));
+
+        return (d < Long.MAX_VALUE ? (long) d : Long.MAX_VALUE);
+    }
+
     // ### sleep
     private static final Primitive SLEEP = new Primitive("sleep", "seconds")
     {
         @Override
         public LispObject execute(LispObject arg) throws ConditionThrowable
         {
-            double d =
-                ((DoubleFloat)arg.multiplyBy(new DoubleFloat(1000))).getValue();
-            if (d < 0)
-                return type_error(arg, list(Symbol.REAL, Fixnum.ZERO));
-            long millis = d < Long.MAX_VALUE ? (long) d : Long.MAX_VALUE;
+
             try {
-                Thread.sleep(millis);
+                Thread.sleep(javaSleepInterval(arg));
             }
             catch (InterruptedException e) {
                 currentThread().processThreadInterrupts();




More information about the armedbear-cvs mailing list