[previous] [up] [next]     [index]
Next: Regular Expressions Up: Threads and Namespaces Previous: Parameter Utilities

Custodians

A custodian manages a collection of threads, file-stream ports, process ports, TCP ports, and TCP listeners.[footnote] Whenever a thread, file-stream port, process port, TCP port, or TCP listener is created, it is placed under the management of the current custodian (as determined by the current-custodian parameter; see section 9.4.1.11). The only power given to a custodian is the authority to shut down all of its managed values.

The values managed by a custodian are only weakly held. This means that a will (see section 12.2) can be executed for a value that is managed by a custodian.

(make-custodian [custodian]) creates a new custodian that is subordinate to the custodian custodian. When custodian is directed (via custodian-shutdown-all) to shut down all of its managed values, the new subordinate custodian is automatically directed to shut down its managed values as well. The default value for custodian is the current custodian.

(custodian-shutdown-all custodian) kills all running threads, closes all open ports, and closes all active TCP listeners that are managed by the custodian custodian. If custodian manages the current thread, the custodian shuts down all other objects before killing the current thread.

(custodian? v) returns #t if v is a custodian value, #f otherwise.



PLT