[plt-scheme] spawning threads in web server

From: David Van Horn (dvanhorn at cs.uvm.edu)
Date: Mon Mar 1 15:05:23 EST 2004

It's easy enough to have a servlet that pauses computation, sends a URL to an 
email address and then resumes once the URL is visited.  I have a slightly 
different situation.  I'd like to have the computation continue for the user, 
but email a URL that will continue down another path of computation when visited.

I use this to notify the administrator about certain user actions that require 
attention.  The administrator is sent a URL that when visited will have forms 
tailored for the specific user and required action.

I had thought something like this would work:

      (form ((action
              ,(lambda (request)
                  (lambda ()
                    ((lambda (request) ...)
                      (lambda (k-url)
                        (send-email admin k-url)
                          (form ;; for admin use.
                  '(html (p "thanks for notifying the admins."))))))

            ... ;; for user use.

But this gives the following error:

Servlet exception: "continuation application: attempted to apply foreign 
continuation (created in another thread)"

I don't see how to do this without spawning a new thread; perhaps I'm 
overlooking something obvious.  Any help would be appreciated.


Posted on the users mailing list.