5.7 Custodian Shutdown Registration
(require ffi/unsafe/custodian) | package: base |
The
ffi/unsafe/custodian library provides utilities for
registering shutdown callbacks with custodians.
procedure
(register-custodian-shutdown v callback [ custodian #:at-exit? at-exit? #:weak? weak?]) → cpointer? v : any/c callback : (any/c . -> . any) custodian : custodian? = (current-custodian) at-exit? : any/c = #f weak? : any/c = #f
Registers callback to be applied (in atomic mode and an
unspecified Racket thread) to v when custodian is
shutdown. The result is a pointer that can be supplied to
unregister-custodian-shutdown to remove the registration.
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.
Normally, weak? should be false. To trigger actions based on
finalization or custodian shutdown—
procedure
(unregister-custodian-shutdown v registration) → void? v : any/c registration : _cpointer
Cancels a custodian-shutdown registration, where registration
is a previous result from register-custodian-shutdown applied
to v.