<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks, Jay. I think that's exactly what I'll do, unless I become
confident that the current way is safe.<br>
<br>
Jay McCarthy wrote at 05/22/2010 10:15 AM:
<blockquote
cite="mid:AANLkTimo7cMMvM9eRAswyDXsARG7J-EkcLUnNdJfrQ7n@mail.gmail.com"
type="cite">
<pre wrap="">I don't know if it is a valid worry. But if it is, you could make
another thread that does this:
(thread (lambda () (let loop (custodian-shutdown-all (channel-get
kill-ch)) (loop))))
and have your original thread do (channel-put kill-ch
(current-custodian)) as its final action.
Jay
On Sat, May 22, 2010 at 8:11 AM, Neil Van Dyke <a class="moz-txt-link-rfc2396E" href="mailto:neil@neilvandyke.org"><neil@neilvandyke.org></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Anyone who knows custodians and threads well have a minute to sanity-check
this for me?
In a conventional TCP server that has one request per connection and creates
a thread for each request... I am currently establishing a new
current-custodian for the block of code that calls "tcp-accept", and having
the thread created within that block call "custodian-shutdown-all" on that
custodian (as the thread's final act). A simplified example:
(let loop ()
(let ((request-cust (make-custodian my-listener-cust)))
(parameterize ((current-custodian request-cust))
(let-values (((in out) (tcp-accept my-listener)))
(thread (lambda ()
(dynamic-wind
(lambda () #f)
(lambda ()
(my-handle-request in out))
(lambda ()
(custodian-shutdown-all request-cust)))))))
(loop)))
This seems to work, but I'm wondering whether there's a race condition
(e.g., custodian shutdown code is executed in the thread itself, and that
code can kill its own evaluation prematurely), and whether there's a better
way to do it.
--
<a class="moz-txt-link-freetext" href="http://www.neilvandyke.org/">http://www.neilvandyke.org/</a>
_________________________________________________
For list-related administrative tasks:
<a class="moz-txt-link-freetext" href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a>
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
</body>
</html>