destroy-thread doesn't seem to honor unwind-protect, and as a result,
such forms as with-mutex. For example, this code should print both
"foo" and "bar", or neither "foo" nor "bar", or even, just possibly,
"bar" without "foo", but never "foo" without "bar":
(let ((id (sb-thread:make-thread #'(lambda ()
(unwind-protect
(progn (format t "foo~%")
(sleep 10))
(format t "bar~%"))))))
(sleep 1)
(sb-thread:destroy-thread id))
Under SBCL 0.8.1.9 (specifically the sbcl-mt package in the Debian
testing distribution) it only prints "foo". (0.8.2.11 seems to have
the same behavior, based on a quick look.) Is this expected? If so, it
would be nice to include it in the documentation of destroy-thread.
Is there any way to get the behavior I want? Without unwind-protect
there seems to be no way to ensure that a mutex is released when a
thread is destroyed, meaning that destroy-thread is unsafe to call on
threads that acquire mutexes.
Thanks!
Geoff Schmidt
gschmidt@...
|