> 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? _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel