Hi all,<div><br></div><div>Reviving an old thread because of some private discussion with James which spun off the LispWorks  users list.</div><div><br></div><div>The comment by Alessio below is one that I've been wondering about for quite some time. What's our ThreadInterrupted "protocol"? Can we design one, if we can't deduce one from code base?</div>
<div><br></div><div>I'm thinking about a protocol which works for the current code in the libraries as well as all code that the compiler generates. Reading up on the documentation for interrupts, it looks like we should be invoking Thread.interrupted() in random places to see if we've been interrupted. Presumably we need to do something with the interrupted information as well, then though.</div>
<div><br></div><div>What more would there be to designing a protocol? We currently seem to be executing lambda expressions which get pushed into a thread-local queue. However, that's far from actually stopping the thread and destroying it.</div>
<div><br></div><div>Well?</div><div><br></div><div>Bye,</div><div><br></div><div><br>Erik.</div><div><br><br><div class="gmail_quote">On Mon, Oct 24, 2011 at 11:34 PM, Alessio Stalla <span dir="ltr"><<a href="mailto:alessiostalla@gmail.com" target="_blank">alessiostalla@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Sun, Oct 23, 2011 at 8:05 PM, James Lawrence <<a href="mailto:llmjjmll@gmail.com">llmjjmll@gmail.com</a>> wrote:<br>

>    (defun test-cleanup ()<br>
>      (let* ((cleanedp nil)<br>
>             (thread (threads:make-thread<br>
>                      (lambda ()<br>
>                        (unwind-protect (sleep 999)<br>
>                          (setf cleanedp t))))))<br>
>        (sleep 0.5)<br>
>        (threads:destroy-thread thread)<br>
>        (sleep 0.5)<br>
>        cleanedp))<br>
><br>
>    (test-cleanup)<br>
><br>
> ABCL-1.0.0 and ABCL-0.27.0 return NIL.<br>
><br>
> Other implementations I tested all return T -- Allegro, Clozure,<br>
> LispWorks, SBCL (changing "threads" to "bordeaux-threads").<br>
><br>
> Of course this isn't a bug since ABCL is free to do what it wishes.<br>
> Does ABCL wish that?<br>
<br>
</div>I don't think we should wish that. It's inconsistent not only with<br>
other Lisp implementations, but with Java thread semantics as well.<br>
The problems are two: first, that destroy-thread doesn't really<br>
destroy the thread, it just sets a flag, so the sleep is not aborted<br>
(when it ends, the next form is not evaluated and the thread just<br>
terminates); second, that sleep swallows the ThreadInterrupted<br>
exception anyway, so even if it were interrupted, the thread would<br>
then continue normally.<br>
I think thread-destroy should be reimplemented to call<br>
Thread.interrupt() and that we should properly handle<br>
InterruptedException as a Lisp condition.<br>
<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
armedbear-devel mailing list<br>
<a href="mailto:armedbear-devel@common-lisp.net">armedbear-devel@common-lisp.net</a><br>
<a href="http://lists.common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel" target="_blank">http://lists.common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel</a><br>
</div></div></blockquote></div><br></div>