[plt-scheme] spawning threads in web server
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:
(send/suspend/dispatch
`(html
(form ((action
,(lambda (request)
...
(thread
(lambda ()
((lambda (request) ...)
(send/suspend
(lambda (k-url)
(send-email admin k-url)
`(html
(form ;; for admin use.
...)))))))
(send/finish
'(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.
Thanks,
David