On Wed, 20 Feb 2008 09:16:58 -0800, Jeff Cunningham jeffrey@cunningham.net wrote:
That one went over my head. Does it mean that if I put a function like this:
(defun cancel-all-threads () (mapcar (lambda (thread) (sb-thread:interrupt-thread thread (lambda () (throw 'hunchentoot::handler-done "")))) (sb-thread:list-all-threads)))
into, say, request.lisp (in hunchentoot), that it would find the tag?
Why don't you try it out yourself?
CL-USER> (defun endless () (format #.*standard-output* "Interrupted by someone throwing ~S.~%" (catch 'foo (loop (sleep 1))))) ENDLESS CL-USER> (defun stop () (throw 'foo 42)) STOP CL-USER> (sb-thread:make-thread 'endless) #<SB-THREAD:THREAD {AEB0E11}> CL-USER> (sb-thread:interrupt-thread * 'stop) Interrupted by someone throwing 42.
But as I already said the catch tag has to be established for this to work. Look at the code, specifically at server.lisp, and you'll see that you can't simply throw HANDLER-DONE at any time during the lifetime of a Hunchentoot thread. Or simply read the docs where it says that you can throw this tag "during the lifetime of a handler."