13.6 Custodians
See Custodians for basic information on the PLT Scheme custodian model.
(custodian? v) → boolean? |
v : any/c |
Returns #t if v is a custodian value, #f otherwise.
(make-custodian [cust]) → custodian? |
cust : custodian? = (current-custodian) |
Creates a new custodian that is subordinate to cust. When cust 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.
(custodian-shutdown-all cust) → void? |
cust : custodian? |
Closes all open ports and closes all active TCP listeners and UDP sockets that are managed by cust. It also removes cust (and its subordinates) as managers of all threads; when a thread has no managers, it is killed (or suspended; see thread/suspend-to-kill) If the current thread is to be killed, all other shut-down actions take place before killing the thread.
(current-custodian cust) → void? |
cust : custodian? |
A parameter that determines a custodian that assumes responsibility for newly created threads, ports, TCP listeners, UDP sockets, and byte converters.
(custodian-managed-list cust super) → list? |
cust : custodian? |
super : custodian? |
Returns a list of immediately managed objects and subordinate custodians for cust, where cust is itself subordinate to super (directly or indirectly). If cust is not strictly subordinate to super, the exn:fail:contract exception is raised.
Returns #t if MzScheme is compiled with support for per-custodian memory accounting, #f otherwise.
Memory accounting is normally available in PLT Scheme 3m, which is the main variant of PLT Scheme, and not normally available in PLT Scheme CGC.
| |||||||||||||||||||||
limit-cust : custodian? | |||||||||||||||||||||
need-amt : nonnegative-exact-integer? | |||||||||||||||||||||
stop-cust : custodian? |
Registers a require check if PLT Scheme is compiled with support for per-custodian memory accounting, otherwise the exn:fail:unsupported exception is raised.
If a check is registered, and if PLT Scheme later reaches a state after garbage collection (see Garbage Collection) where allocating need-amt bytes charged to limit-cust would fail or tigger some shutdown, then stop-cust is shut down.
| |||||||||||||||||||||
limit-cust : custodian? | |||||||||||||||||||||
limit-amt : nonnegative-exact-integer? | |||||||||||||||||||||
stop-cust : custodian? = limit-cust |
Registers a limit check if PLT Scheme is compiled with support for per-custodian memory accounting, otherwise the exn:fail:unsupported exception is raised.
If a check is registered, and if PLT Scheme later reaches a state after garbage collection (see Garbage Collection) where limit-cust owns more than limit-amt bytes, then stop-cust is shut down.
For reliable shutdown, limit-amt for custodian-limit-memory must be much lower than the total amount of memory available (minus the size of memory that is potentially used and not charged to limit-cust). Moreover, if indvidual allocations that are initially charged to limit-cust can be arbitrarily large, then stop-cust must be the same as limit-cust, so that excessively large immediate allocations can be rejected with an exn:fail:out-of-memory exception.
(make-custodian-box cust v) → custodian-box? |
cust : custodian? |
v : any/c |
Returns a custodian box that contains v as long as cust has not been shut down.
(custodian-box? v) → boolean? |
v : any/c |
Returns #t if v is a custodian box produced by make-custodian-box, #f otherwise.
(custodian-box-value cb) → any |
cb : custodian-box? |
Rturns the value in the given custodian box, or #f if the value has been removed.