GNU bug report logs -
#63311
30.0.50; [PATCH] smtpmail-send-it split
Previous Next
Full log
View this message in rfc822 format
> From: Manuel Giraud <manuel <at> ledu-giraud.fr>
> Cc: 63311 <at> debbugs.gnu.org
> Date: Thu, 11 May 2023 22:59:20 +0200
>
> (defun my-problem ()
> (interactive)
> (let ((buf (generate-new-buffer "*foo*")))
> (with-current-buffer buf
> (insert "secret message"))
> (unwind-protect
> (make-thread #'(lambda ()
> (with-current-buffer buf
> (sit-for 10)
> (message (buffer-string)))))
> (kill-buffer buf))))
> --8<---------------cut here---------------end--------------->8---
>
> The thread won't have a chance to do its job since the buffer will
> already be dead.
Of course. So you cannot do that, obviously. Cleanup that gets in
the way of code you run in a thread must be done after thread-join
returns, or when thread-live-p returns nil for the thread. Or use
some other synchronization method. There could be several such
threads alive at the same time, btw.
In the unwind-protect handler of the main thread you can only do
cleanup of stuff that the thread doesn't need, or if you are sure the
thread was not started (due to some error that precludes the call to
make-thread).
I'm not aware of any other machinery we have for these cases.
This bug report was last modified 1 year and 220 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.