<div dir="ltr"><div style>Hello,</div><div style><br></div><div style>is there a reason why interrupt-thread doesn't seem to run the requested function in some cases? The following code tries to run a function in each existing thread (the variable *output* logs the calls that we try to run and the ones that are actually run).</div>
<div><br></div><div>(defvar *output*)</div><div><br></div><div>(defun test-run ()</div><div> (setf *output* nil)</div><div> (threads:mapcar-threads</div><div> (lambda (thread)</div><div> (push (format nil "~A : calling" thread) *output*)</div>
<div> (threads:interrupt-thread thread</div><div><span class="" style="white-space:pre"> </span> (lambda () </div><div><span class="" style="white-space:pre"> </span> (push (format nil "~A : running" thread) *output*))))))</div>
<div><br></div><div>(defun test-report ()</div><div> (format t "~{~A~%~}" (reverse *output*)))</div><div><br></div><div style>Running in the command line:</div><div><br></div><div><div>CL-USER(5): (threads:make-thread #'test-run :name "TEST-RUN")</div>
<div>#<THREAD "TEST-RUN" {49BBE826}></div><div><br></div><div>CL-USER(6): (test-report)</div><div>#<THREAD "TEST-RUN" {49BBE826}> : calling</div><div>#<THREAD "interpreter" {409CB8AF}> : calling</div>
<div><br></div></div><div style>I can understand that the thread "TEST-RUN" that I create to run the function might disappear before it gets to run the function as requested, or maybe the reason is that a thread can't interrupt itself by design... But why doesn't the thread "interpreter" run the function?</div>
<div style><br></div><div style>Running in slime there are many threads present, and most of them will respond as expected. But "TEST-RUN", "interpreter" and "reader-thread" won't.</div><div style>
</div><div style><div>#<THREAD "control-thread" {3C036436}> : calling</div><div>#<THREAD "reader-thread" {10A08BAA}> : calling</div><div>#<THREAD "swank-indentation-cache-thread" {2A83402}> : calling</div>
<div>#<THREAD "Swank Sentinel" {66E71110}> : calling</div><div>#<THREAD "repl-thread" {699D8335}> : calling</div><div>#<THREAD "Swank Sentinel" {66E71110}> : running</div><div>
#<THREAD "TEST-RUN" {4E0267BA}> : calling</div><div>#<THREAD "repl-thread" {699D8335}> : running</div><div>#<THREAD "auto-flush-thread" {6913E490}> : calling</div><div>#<THREAD "interpreter" {1902DFD5}> : calling</div>
<div>#<THREAD "auto-flush-thread" {6913E490}> : running</div><div>#<THREAD "swank-indentation-cache-thread" {2A83402}> : running</div><div>#<THREAD "control-thread" {3C036436}> : running</div>
<div><br></div><div style>Cheers,</div><div style><br></div><div style>Carlos</div></div></div>