Previous: Fibers, Up: Scheme reference [Contents][Index]
The (hoot finalization)
module provides an interface for the
JavaScript
FinalizationRegistry
class, which notifies user code when a registered object has been
garbage collected. Finalization registries are quite different from
Guile’s guardians:
The following contrived example will print “hey” when the registered object is garbage collected:
(define (cleanup x) (display x) (newline)) (define registry (make-finalization-registry cleanup)) (finalization-registry-register! registry (list 'garbage) 'hey)
Return a new finalization registry that will call cleanup (a procedure of one argument) whenever a registered object is garbage collected.
Return #t if obj is a finalization registry.
Register target with registry. When target is
garbage collected, the cleanup callback will receive held-value.
held-value cannot be eq?
to target.
If unregister-token is specified and not #f
then this
token can be used to unregister target later.
Unregister the objects associated with unregister-token from registry. Return #t if at least one object was unregistered this way.
Previous: Fibers, Up: Scheme reference [Contents][Index]