3 ms·
Maintain a collection of objects with finalizers associated with the generation; when an object is moved out of the generation, move the finalizer record with i
by mcguire 6y ago
Maintain a collection of objects with finalizers associated with the generation; when an object is moved out of the generation, move the finalizer record with it. Then, just before the generation is discarded, run the finalizers.
If the finalizers do something stupid like resurrect the object, have the runtime system notify someone with the authority to go beat the programmer with a stick.
- Avi-D-coder 6y agoInterestingly for the Rust GC I'm working both Drop and finalizers will be supported. Do you happen to offer beat the programmer with a stick as a service?
- mcguire 6y agoUnfortunately, no, but you are going to need it. I was fooling with a cycle-collected reference counter for Rust for a while, but eventually gave up because of the difficulty in handling finalizers.