<p dir="ltr">Hi James,<br></p>
<p dir="ltr">Thanks for confirming that.</p>
<p dir="ltr">What would you consider the best option when the timeout value becomes too close to 0? I see 2:</p>
<p dir="ltr">1. Don't wait.<br>
2. Wait at least 1 ns<br></p>
<p dir="ltr">Bye,<br></p>
<p dir="ltr">Erik.<br>
</p>
<div class="gmail_quote">On Feb 1, 2014 7:50 PM, "James M. Lawrence" <<a href="mailto:llmjjmll@gmail.com">llmjjmll@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi, this fixes time=0 and time=0.0001, but it still hangs with<br>
time=0.000000001 and smaller positive values.<br>
<br>
<br>
On Sat, Feb 1, 2014 at 11:36 AM, Erik Huelsmann <<a href="mailto:ehuels@gmail.com">ehuels@gmail.com</a>> wrote:<br>
> Hi James,<br>
><br>
> My thinking is that the wait time is being rounded to zero, which might be<br>
> used internally by Java to encode an indefinite wait.<br>
><br>
> Does the patch below work for you?<br>
><br>
> Bye,<br>
><br>
> Erik.<br>
><br>
><br>
> Index: LispThread.java<br>
> ===================================================================<br>
> --- LispThread.java (revision 14464)<br>
> +++ LispThread.java (working copy)<br>
> @@ -1004,11 +1004,12 @@<br>
> };<br>
><br>
><br>
> + private static DoubleFloat factor1000 = new DoubleFloat(1000);<br>
> +<br>
> public static final long javaSleepInterval(LispObject lispSleep)<br>
> -<br>
> {<br>
> double d =<br>
> - checkDoubleFloat(lispSleep.multiplyBy(new<br>
> DoubleFloat(1000))).getValue();<br>
> + checkDoubleFloat(lispSleep.multiplyBy(factor1000)).getValue();<br>
> if (d < 0)<br>
> type_error(lispSleep, list(Symbol.REAL, Fixnum.ZERO));<br>
><br>
> @@ -1015,6 +1016,17 @@<br>
> return (d < Long.MAX_VALUE ? (long) d : Long.MAX_VALUE);<br>
> }<br>
><br>
> + public static final int javaSleepNanos(LispObject lispSleep)<br>
> + {<br>
> + double d = // d contains millis<br>
> + checkDoubleFloat(lispSleep.multiplyBy(factor1000)).getValue();<br>
> + double n = d*1000000; // n contains nanos<br>
> + d = 1.0e6*((long)d); // convert rounded millis to nanos<br>
> + n = n - d; // retain nanos not in millis<br>
> +<br>
> + return (n < Integer.MAX_VALUE ? (int) n : Integer.MAX_VALUE);<br>
> + }<br>
> +<br>
> @DocString(name="sleep", args="seconds",<br>
> doc="Causes the invoking thread to sleep for SECONDS seconds.\n"+<br>
> "SECONDS may be a value between 0 1and 1.")<br>
> @@ -1025,7 +1037,8 @@<br>
> {<br>
><br>
> try {<br>
> - Thread.sleep(javaSleepInterval(arg));<br>
> + Thread.sleep(javaSleepInterval(arg),<br>
> + javaSleepNanos(arg));<br>
> }<br>
> catch (InterruptedException e) {<br>
> currentThread().processThreadInterrupts();<br>
> @@ -1208,7 +1221,8 @@<br>
><br>
> {<br>
> try {<br>
> - object.lockableInstance().wait(javaSleepInterval(timeout));<br>
> + object.lockableInstance().wait(javaSleepInterval(timeout),<br>
> + javaSleepNanos(timeout));<br>
> }<br>
> catch (InterruptedException e) {<br>
> currentThread().processThreadInterrupts();<br>
><br>
><br>
><br>
><br>
> On Sat, Feb 1, 2014 at 2:54 PM, James M. Lawrence <<a href="mailto:llmjjmll@gmail.com">llmjjmll@gmail.com</a>><br>
> wrote:<br>
>><br>
>> (defun test ()<br>
>> (let ((object (cons nil nil)))<br>
>> (threads:synchronized-on object<br>
>> (threads:object-wait object 0.0001))))<br>
>><br>
>> For times between 0 and 0.0001 this appears to hang indefinitely. No<br>
>> problem with times above 0.001.<br>
>><br>
>> The context is the new timeout option for bordeaux-threads:condition-wait,<br>
>><br>
>><br>
>> <a href="https://github.com/sionescu/bordeaux-threads/blob/master/src/impl-abcl.lisp#L101" target="_blank">https://github.com/sionescu/bordeaux-threads/blob/master/src/impl-abcl.lisp#L101</a><br>
>><br>
>> 1.3.0-dev-svn-14623<br>
>> Java_HotSpot(TM)_Server_VM-Oracle_Corporation-1.7.0_04-b20<br>
>> i386-Linux-3.2.0-24-generic-pae<br>
>><br>
>> Best,<br>
>> lmj<br>
>><br>
><br>
><br>
><br>
> --<br>
> Bye,<br>
><br>
> Erik.<br>
><br>
> <a href="http://efficito.com" target="_blank">http://efficito.com</a> -- Hosted accounting and ERP.<br>
> Robust and Flexible. No vendor lock-in.<br>
<br>
</blockquote></div>