<br><div class="gmail_quote">On Mon, Mar 23, 2009 at 8:57 PM, Chongkai Zhu <span dir="ltr"><<a href="mailto:czhu@cs.utah.edu">czhu@cs.utah.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
It seems that memory served me wrong: only when writing C code, you can put objects under the management of custodians. <a href="http://docs.plt-scheme.org/inside/Custodians.html" target="_blank">http://docs.plt-scheme.org/inside/Custodians.html</a><br>
<br>
For Scheme code, dynamic-wind would be more appropriate.<br><font color="#888888">
</font></blockquote><div><br>Thanks Chongkai for thoughts on custodian & dynamic-wind. <br><br>I think dynamic-wind doesn't fit the long-living objects I am describing, unless the dynamic-wind is used at the top level. I am thinking of objects that live as long as modules (i.e. from the point of require to the point of program exit).<br>
<br>An example is a module that abstracts its persistence mechanism. Let's say we have a module foo that provides log-foo-event, but doesn't expose the underlying instantiation and closure of database. So when you require module foo, the database is automatically instantiated in the background.<br>
<br>The abstracted database connection doesn't close until the module is unloaded (generally when mzscheme exits), and it needs some explicit clean up code (like ensurely there are no leftover locks etc).<br><br>Custodians do not appear to have ability to execute custom code when an object is being shutdown.<br>
<br>Will appears to run when the object is not reachable, but such long living objects will probably be always reachable, so it also doesn't appear to be a fit.<br><br>If there is something that combines the feature of custodian & will it would probably do the trick.<br>
<br>Thanks,<br>yc<br><br><br><br><br><br><br></div></div>