/usr/share/doc/racket/inside/Custodians.html is in racket-doc 6.7-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>18 Custodians</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_0");">▼</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">Inside:<span class="mywbr"> </span> Racket C API</a></td></tr></table></div><div class="tocviewsublistonly" style="display: block;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1 </td><td><a href="overview.html" class="tocviewlink" data-pltdoc="x">Overview</a></td></tr><tr><td align="right">2 </td><td><a href="embedding.html" class="tocviewlink" data-pltdoc="x">Embedding into a Program</a></td></tr><tr><td align="right">3 </td><td><a href="Writing_Racket_Extensions.html" class="tocviewlink" data-pltdoc="x">Writing Racket Extensions</a></td></tr><tr><td align="right">4 </td><td><a href="im_values_types.html" class="tocviewlink" data-pltdoc="x">Values and Types</a></td></tr><tr><td align="right">5 </td><td><a href="im_memoryalloc.html" class="tocviewlink" data-pltdoc="x">Memory Allocation</a></td></tr><tr><td align="right">6 </td><td><a href="im_env.html" class="tocviewlink" data-pltdoc="x">Namespaces and Modules</a></td></tr><tr><td align="right">7 </td><td><a href="Procedures.html" class="tocviewlink" data-pltdoc="x">Procedures</a></td></tr><tr><td align="right">8 </td><td><a href="Evaluation.html" class="tocviewlink" data-pltdoc="x">Evaluation</a></td></tr><tr><td align="right">9 </td><td><a href="exceptions.html" class="tocviewlink" data-pltdoc="x">Exceptions and Escape Continuations</a></td></tr><tr><td align="right">10 </td><td><a href="threads.html" class="tocviewlink" data-pltdoc="x">Threads</a></td></tr><tr><td align="right">11 </td><td><a href="config.html" class="tocviewlink" data-pltdoc="x">Parameterizations</a></td></tr><tr><td align="right">12 </td><td><a href="contmarks.html" class="tocviewlink" data-pltdoc="x">Continuation Marks</a></td></tr><tr><td align="right">13 </td><td><a href="im_encodings.html" class="tocviewlink" data-pltdoc="x">String Encodings</a></td></tr><tr><td align="right">14 </td><td><a href="Bignums__Rationals__and_Complex_Numbers.html" class="tocviewlink" data-pltdoc="x">Bignums, Rationals, and Complex Numbers</a></td></tr><tr><td align="right">15 </td><td><a href="Ports_and_the_Filesystem.html" class="tocviewlink" data-pltdoc="x">Ports and the Filesystem</a></td></tr><tr><td align="right">16 </td><td><a href="Structures.html" class="tocviewlink" data-pltdoc="x">Structures</a></td></tr><tr><td align="right">17 </td><td><a href="security.html" class="tocviewlink" data-pltdoc="x">Security Guards</a></td></tr><tr><td align="right">18 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Custodians</a></td></tr><tr><td align="right">19 </td><td><a href="Subprocesses.html" class="tocviewlink" data-pltdoc="x">Subprocesses</a></td></tr><tr><td align="right">20 </td><td><a href="Miscellaneous_Utilities.html" class="tocviewlink" data-pltdoc="x">Miscellaneous Utilities</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</a></td></tr></table></div></div></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.7", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.7");">top</a></span><span class="navright"> <a href="security.html" title="backward to "17 Security Guards"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "Inside: Racket C API"" data-pltdoc="x">up</a> <a href="Subprocesses.html" title="forward to "19 Subprocesses"" data-pltdoc="x">next →</a></span> </div><h3 x-source-module="(lib "scribblings/inside/inside.scrbl")" x-source-pkg="racket-doc" x-part-tag=""Custodians"">18<tt> </tt><a name="(part._.Custodians)"></a>Custodians</h3><p>When an extension allocates resources that must be explicitly freed
(in the same way that a port must be explicitly closed), a Racket
object associated with the resource should be placed into the
management of the current custodian with <a href="#%28cpp._scheme_add_managed%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_add_managed</span></a>.</p><p>Before allocating the resource, call
<a href="#%28cpp._scheme_custodian_check_available%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_custodian_check_available</span></a> to ensure that the relevant
custodian is not already shut down. If it is,
<a href="#%28cpp._scheme_custodian_check_available%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_custodian_check_available</span></a> will raise an exception. If
the custodian is shut down when <a href="#%28cpp._scheme_add_managed%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_add_managed</span></a> is called,
the close function provided to <a href="#%28cpp._scheme_add_managed%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_add_managed</span></a> will be called
immediately, and no exception will be reported.</p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="boxed"><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">Scheme_Custodian*</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><a name="(cpp._scheme_make_custodian)"></a><a name="(idx._(gentag._576._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_make_custodian%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_make_custodian</span></a></p></td><td><p><span class="stt">(</span></p></td><td><p><span class="stt">Scheme_Custodian*</span><span class="hspace"> </span><span style="font-style: italic">m</span><span class="stt">)</span></p></td></tr></table></td></tr></table></div><div class="SIntrapara">Creates a new custodian as a subordinate of <span style="font-style: italic">m</span>. If <span style="font-style: italic">m</span> is
<span class="stt">NULL</span>, then the main custodian is used as the new custodian’s
supervisor. Do not use <span class="stt">NULL</span> for <span style="font-style: italic">m</span> unless you intend to
create an especially privileged custodian.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="boxed"><tr><td><table cellspacing="0" cellpadding="0"><tr><td colspan="3"><p><span class="stt">Scheme_Custodian_Reference*</span></p></td></tr><tr><td><p><a name="(cpp._scheme_add_managed)"></a><a name="(idx._(gentag._577._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_add_managed%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_add_managed</span></a></p></td><td><p><span class="stt">(</span></p></td><td><p><span class="stt">Scheme_Custodian*</span><span class="hspace"> </span><span style="font-style: italic">m</span><span class="stt">,</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">Scheme_Object*</span><span class="hspace"> </span><span style="font-style: italic">o</span><span class="stt">,</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">Scheme_Close_Custodian_Client*</span><span class="hspace"> </span><span style="font-style: italic">f</span><span class="stt">,</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">void*</span><span class="hspace"> </span><span style="font-style: italic">data</span><span class="stt">,</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">int</span><span class="hspace"> </span><span style="font-style: italic">strong</span><span class="stt">)</span></p></td></tr></table></td></tr></table></div><div class="SIntrapara">Places the value <span style="font-style: italic">o</span> into the management of the custodian
<span style="font-style: italic">m</span>. If <span style="font-style: italic">m</span> is <span class="stt">NULL</span>, the current custodian is used.</div></p><p>The <span style="font-style: italic">f</span> function is called by the custodian if it is ever asked to
“shutdown” its values; <span style="font-style: italic">o</span> and <span style="font-style: italic">data</span> are passed on to
<span style="font-style: italic">f</span>, which has the type</p><p><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">typedef void (*Scheme_Close_Custodian_Client)(Scheme_Object *o,</span></p></td></tr><tr><td><p><span class="stt"></span><span class="hspace"> </span><span class="stt">void *data);</span></p></td></tr></table></p><p>If <span style="font-style: italic">strong</span> is non-zero, then the newly managed value will
be remembered until either the custodian shuts it down or
<a href="#%28cpp._scheme_remove_managed%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_remove_managed</span></a> is called. If <span style="font-style: italic">strong</span> is
zero, the value is allowed to be garbage collected (and automatically
removed from the custodian).</p><p>Independent of whether <span style="font-style: italic">strong</span> is zero, the value <span style="font-style: italic">o</span> is
initially weakly held. A value associated with a custodian can
therefore be finalized via will executors.</p><p>The return value from <a href="#%28cpp._scheme_add_managed%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_add_managed</span></a> can be used to refer
to the value’s custodian later in a call to
<a href="#%28cpp._scheme_remove_managed%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_remove_managed</span></a>. A value can be registered with at
most one custodian.</p><p>If <span style="font-style: italic">m</span> (or the current custodian if <span style="font-style: italic">m</span> is <span class="stt">NULL</span>)is shut
down, then <span style="font-style: italic">f</span> is called immediately, and the result is
<span class="stt">NULL</span>.</p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="boxed"><tr><td><table cellspacing="0" cellpadding="0"><tr><td colspan="3"><p><span class="stt">Scheme_Custodian_Reference*</span></p></td></tr><tr><td><p><a name="(cpp._scheme_add_managed_close_on_exit)"></a><a name="(idx._(gentag._578._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_add_managed_close_on_exit%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_add_managed_close_on_exit</span></a></p></td><td><p><span class="stt">(</span></p></td><td><p><span class="stt">Scheme_Custodian*</span><span class="hspace"> </span><span style="font-style: italic">m</span><span class="stt">,</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">Scheme_Object*</span><span class="hspace"> </span><span style="font-style: italic">o</span><span class="stt">,</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">Scheme_Close_Custodian_Client*</span><span class="hspace"> </span><span style="font-style: italic">f</span><span class="stt">,</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">void*</span><span class="hspace"> </span><span style="font-style: italic">data</span><span class="stt">)</span></p></td></tr></table></td></tr></table></div><div class="SIntrapara">Like <a href="#%28cpp._scheme_add_managed%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_add_managed</span></a> with a <span class="stt">1</span> final argument, but also
causes <span style="font-style: italic">f</span> to be called when Racket exists without an explicit
custodian shutdown.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="boxed"><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">void</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><a name="(cpp._scheme_custodian_check_available)"></a><a name="(idx._(gentag._579._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_custodian_check_available%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_custodian_check_available</span></a></p></td><td><p><span class="stt">(</span></p></td><td><p><span class="stt">Scheme_Custodian*</span><span class="hspace"> </span><span style="font-style: italic">m</span><span class="stt">,</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">const char*</span><span class="hspace"> </span><span style="font-style: italic">name</span><span class="stt">,</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">const char*</span><span class="hspace"> </span><span style="font-style: italic">resname</span><span class="stt">)</span></p></td></tr></table></td></tr></table></div><div class="SIntrapara">Checks whether <span style="font-style: italic">m</span> is already shut down, and raises an error if
so. If <span style="font-style: italic">m</span> is <span class="stt">NULL</span>, the current custodian is used. The
<span style="font-style: italic">name</span> argument is used for error reporting. The <span style="font-style: italic">resname</span>
argument will likely be used for checking pre-set limits in the
future; pre-set limits will have symbolic names, and the
<span style="font-style: italic">resname</span> string will be compared to the symbols.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="boxed"><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">void</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><a name="(cpp._scheme_remove_managed)"></a><a name="(idx._(gentag._580._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_remove_managed%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_remove_managed</span></a></p></td><td><p><span class="stt">(</span></p></td><td><p><span class="stt">Scheme_Custodian_Reference*</span><span class="hspace"> </span><span style="font-style: italic">mref</span><span class="stt">,</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">Scheme_Object*</span><span class="hspace"> </span><span style="font-style: italic">o</span><span class="stt">)</span></p></td></tr></table></td></tr></table></div><div class="SIntrapara">Removes <span style="font-style: italic">o</span> from the management of its custodian. The <span style="font-style: italic">mref</span>
argument must be a value returned by <a href="#%28cpp._scheme_add_managed%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_add_managed</span></a> or
<span class="stt">NULL</span>.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="boxed"><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">void</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><a name="(cpp._scheme_close_managed)"></a><a name="(idx._(gentag._581._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_close_managed%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_close_managed</span></a></p></td><td><p><span class="stt">(</span></p></td><td><p><span class="stt">Scheme_Custodian*</span><span class="hspace"> </span><span style="font-style: italic">m</span><span class="stt">)</span></p></td></tr></table></td></tr></table></div><div class="SIntrapara">Instructs the custodian <span style="font-style: italic">m</span> to shutdown all of its managed values.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="boxed"><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">void</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><a name="(cpp._scheme_add_atexit_closer)"></a><a name="(idx._(gentag._582._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_add_atexit_closer%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_add_atexit_closer</span></a></p></td><td><p><span class="stt">(</span></p></td><td><p><span class="stt">Scheme_Exit_Closer_Func</span><span class="hspace"> </span><span style="font-style: italic">f</span><span class="stt">)</span></p></td></tr></table></td></tr></table></div><div class="SIntrapara">Installs a function to be called on each custodian-registered item and
its closer when Racket is about to exit. The registered function
has the type</div></p><p><table cellspacing="0" cellpadding="0"><tr><td><p><span class="hspace"> </span><span class="stt">typedef</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">void (*Scheme_Exit_Closer_Func)(Scheme_Object *o,</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">Scheme_Close_Custodian_Client *f,</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">void *d);</span></p></td></tr></table></p><p>where <span style="font-style: italic">d</span> is the second argument for <span style="font-style: italic">f</span>.</p><p>At-exit functions are run in reverse of the order that they are
added. An at-exit function is initially registered (and therefore runs
last) that flushes each file-stream output port and calls every
function registered with <a href="#%28cpp._scheme_add_managed_close_on_exit%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_add_managed_close_on_exit</span></a>.</p><p>An at-exit function should not necessarily apply the closer function
for every object that it is given. In particular, shutting down a
file-stream output port would disable the flushing action of the final
at-exit function. Typically, an at-exit function ignores most objects
while handling a specific type of object that requires a specific
clean-up action before the OS-level process terminates.</p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.7", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.7");">top</a></span><span class="navright"> <a href="security.html" title="backward to "17 Security Guards"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "Inside: Racket C API"" data-pltdoc="x">up</a> <a href="Subprocesses.html" title="forward to "19 Subprocesses"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html>
|