[armedbear-devel] hang with threads:object-wait
Mark Evenson
evenson at panix.com
Sat Feb 1 16:50:58 UTC 2014
Confirmed that the java.lang.Object.wait(int, int) interface exists in [java5][].
[java5]: http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html
On Feb 1, 2014, at 17:36, Erik Huelsmann <ehuels at gmail.com> wrote:
> Index: LispThread.java
> ===================================================================
> --- LispThread.java (revision 14464)
> +++ LispThread.java (working copy)
> @@ -1004,11 +1004,12 @@
> };
>
>
> + private static DoubleFloat factor1000 = new DoubleFloat(1000);
> +
> public static final long javaSleepInterval(LispObject lispSleep)
> -
> {
> double d =
> - checkDoubleFloat(lispSleep.multiplyBy(new DoubleFloat(1000))).getValue();
> + checkDoubleFloat(lispSleep.multiplyBy(factor1000)).getValue();
> if (d < 0)
> type_error(lispSleep, list(Symbol.REAL, Fixnum.ZERO));
>
> @@ -1015,6 +1016,17 @@
> return (d < Long.MAX_VALUE ? (long) d : Long.MAX_VALUE);
> }
>
> + public static final int javaSleepNanos(LispObject lispSleep)
> + {
> + double d = // d contains millis
> + checkDoubleFloat(lispSleep.multiplyBy(factor1000)).getValue();
> + double n = d*1000000; // n contains nanos
> + d = 1.0e6*((long)d); // convert rounded millis to nanos
> + n = n - d; // retain nanos not in millis
> +
> + return (n < Integer.MAX_VALUE ? (int) n : Integer.MAX_VALUE);
> + }
> +
> @DocString(name="sleep", args="seconds",
> doc="Causes the invoking thread to sleep for SECONDS seconds.\n"+
> "SECONDS may be a value between 0 1and 1.")
> @@ -1025,7 +1037,8 @@
> {
>
> try {
> - Thread.sleep(javaSleepInterval(arg));
> + Thread.sleep(javaSleepInterval(arg),
> + javaSleepNanos(arg));
> }
> catch (InterruptedException e) {
> currentThread().processThreadInterrupts();
> @@ -1208,7 +1221,8 @@
>
> {
> try {
> - object.lockableInstance().wait(javaSleepInterval(timeout));
> + object.lockableInstance().wait(javaSleepInterval(timeout),
> + javaSleepNanos(timeout));
> }
> catch (InterruptedException e) {
> currentThread().processThreadInterrupts();
--
"A screaming comes across the sky. It has happened before but there is nothing
to compare to it now."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/armedbear-devel/attachments/20140201/bfcd6044/attachment.html>
More information about the armedbear-devel
mailing list