[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: thread cancellation, take 2
From: |
Julian Graham |
Subject: |
Re: thread cancellation, take 2 |
Date: |
Mon, 24 Sep 2007 11:39:10 -0400 |
> I find it more elegant to use closures to that end. I.e., when
> installing a handler, you'd write something like this:
>
> (let ((cleanup (thread-cleanup-procedure (current-thread))))
> (set-thread-cleanup-procedure! (current-thread)
> (lambda ()
> ;; invoke previous handler
> (if (procedure? cleanup)
> (cleanup))
> ;; clean up...
> )))
>
> There's a race here in case multiple threads try to change the cleanup
> procedure associated with that particular thread at the same time, but I
> suppose it is not an issue in practice.
Fair enough, re: closures. But why should callers outside the current
thread be able to access that thread's cleanup handler procedure?
Maybe this isn't a realistic issue, but you could use this to "inject"
arbitrary code into a separate thread by setting the cleanup procedure
and immediately canceling the thread. Why not treat the handler as
thread-specific data?
- thread cancellation, take 2, Julian Graham, 2007/09/20
- Re: thread cancellation, take 2, Ludovic Courtès, 2007/09/20
- Re: thread cancellation, take 2, Julian Graham, 2007/09/20
- Re: thread cancellation, take 2, Julian Graham, 2007/09/23
- Re: thread cancellation, take 2, Ludovic Courtès, 2007/09/23
- Re: thread cancellation, take 2, Julian Graham, 2007/09/23
- Re: thread cancellation, take 2, Ludovic Courtès, 2007/09/24
- Re: thread cancellation, take 2,
Julian Graham <=
- Re: thread cancellation, take 2, Julian Graham, 2007/09/24
- Re: thread cancellation, take 2, Ludovic Courtès, 2007/09/26
- Re: thread cancellation, take 2, Julian Graham, 2007/09/26