5.7 Custodian Shutdown Registration
(require ffi/unsafe/custodian) | package: base |
procedure
(register-custodian-shutdown v callback [ custodian #:at-exit? at-exit? #:weak? weak? #:ordered? ordered?]) → cpointer? v : any/c callback : (any/c . -> . any) custodian : custodian? = (current-custodian) at-exit? : any/c = #f weak? : any/c = #f ordered? : any/c = #f
If at-exit? is true, then callback is applied when Racket exits, even if the custodian is not explicitly shut down.
If weak? is true, then callback may not be called if v is determined to be unreachable during garbage collection. The value v is always weakly held by the custodian, even if weak? is #f; see scheme_add_managed for more information.
If ordered? is true when weak is #f, then v is retained in a way that allows finalization of v via register-finalizer to proceed.
Normally, weak? should be false. To trigger actions based on
finalization or custodian shutdown—
Changed in version 7.8.0.8 of package base: Added the #:ordered? argument.
procedure
(unregister-custodian-shutdown v registration) → void? v : any/c registration : cpointer?
procedure
(register-finalizer-and-custodian-shutdown v callback [ custodian #:at-exit? at-exit? #:custodian-unavailable unavailable-callback]) → any v : any/c callback : (any/c . -> . any) custodian : custodian? = (current-custodian) at-exit? : any/c = #f
unavailable-callback : ((-> void?) -> any) = (lambda (reg-fnl) (reg-fnl))
If custodian is already shut down, then unavailable-callback is applied in tail position to a function that registers a finalizer. By default, a finalizer is registered anyway, but usually a better choice is to report an error. If custodian is not already shut down, then the result from register-finalizer-and-custodian-shutdown is #<void>.
Added in version 6.1.1.6 of package base.
procedure
Creating a child of the root custodian is useful for registering a shutdown function that will be triggered only when the current place terminates.
Added in version 6.9.0.5 of package base.