[racket] How to execute all pending wills in a will-executor?

From: Stephan Houben (stephanh at planet.nl)
Date: Thu Apr 12 09:11:02 EDT 2012

Hi list,

Suppose I have a will-executor and I have arrived at a safe point.
Now I want to execute any pending wills.

So my first idea is to repeatedly call will-try-execute until it returns #f.
However, what if any of the wills itself returns #f ?
Then the loop will terminate prematurely.


This is intended to be used in the RacketGL library (OpenGL library).
For higher-level code it would often be useful to register a finalizer
to clean up GL objects (e.g. textures). However all the GL procedures have to be called
when an OpenGL context is active, so they cannot be called at the point
when GC runs.

My proposed solution: have the RacketGL library provide a will executor
to the user, which can be used to register finalizers with.
Any GL call will first run pending wills.
Since the Racket GL library has no control over what wills are being registered,
it cannot exclude the possibility that some will returns #f.


Posted on the users mailing list.