Previous: iklib guardians examples, Up: iklib guardians [Index]
Build and return a new guardian object: a closure that can be called with one or zero arguments, and that is interfaced with the garbage collector of Vicare in a non–portable way.
The guardian work like this:
#f
.
After an object has been returned by the guardian, it is no more “guarded” so it will be garbage collected when it will become inaccessible (unless it is again registered in a guardian).
NOTE It is possible to register an object in more than one guardian; when the object is found inaccessible all the guardian closures that have it will return it to the caller. This may lead to invalid finalisation operations, it is the responsibility of the programmer to avoid this.
NOTE It is possible to register an object multiple times in the same guardian; when the object is found inaccessible the guardian closure that has it will return it to the caller multiple times. This may lead to invalid finalisation operations, it is the responsibility of the programmer to avoid this.
Hold a list of thunks evaluated after each garbage collection run. It can be used to run a guardian cleanup function like this (using the example in the previous section):
(define (run-block-guardian) (do ((p (block-guardian) (block-guardian))) ((not p)) (free p))) (post-gc-hooks (cons run-block-guardian (post-gc-hooks)))
Previous: iklib guardians examples, Up: iklib guardians [Index]