When an extension allocates resources that must be explicitly freed (in the same way that a port must be explicitly closed), a Scheme object associated with the resource should be placed into the management of the current custodian with scheme_add_managed.
Before allocating the resource, call scheme_custodian_check_available to ensure that the relevant custodian is not already shut down. If it is, scheme_custodian_check_available will raise an exception. If the custodian is shut down when scheme_add_managed is called, the close function provided to scheme_add_managed will be called immediately, and no exception will be reported.
Creates a new custodian as a subordinate of
NULL, then the main custodian is used as the new custodian's
supervisor. Do not use NULL for
m unless you intend to
create an especially privileged custodian.
Places the value
o into the management of the custodian
m is NULL, the current custodian is used.
f function is called by the custodian if it is ever asked to
``shutdown'' its values;
data are passed on to
f, which has the type
typedef void (*Scheme_Close_Custodian_Client)(Scheme_Object *o, void *data);
strong is non-zero, then the newly managed value will
be remembered until either the custodian shuts it down or
scheme_remove_managed is called. If
zero, the value is allowed to be garbaged collected (and automatically
removed from the custodian).
The return value from scheme_add_managed can be used to refer to the value's custodian later in a call to scheme_remove_managed. A value can be registered with at most one custodian.
m (or the current custodian if
m is NULL)is shut
f is called immediately, and the result is
m is already shut down, and raises an error if
m is NULL, the current custodian is used. The
name argument is used for error reporting. The
argument will likely be used for checking pre-set limits in the
future; pre-set limits will have symbolic names, and the
resname string will be compared to the symbols.
o from the management of its custodian. The
argument must be a value returned by scheme_add_managed or
Instructs the custodian
m to shutdown all of its managed values.
Installs a function to be called on each custodian-registered item and its closer when MzScheme is about to exit. The registered function has the type
typedef void (*Scheme_Exit_Closer_Func)(Scheme_Object *o, Scheme_Close_Custodian_Client *f, void *d);
d is the second argument for