Hi guys,
I'm busy writing a partial binding (not at all ready for any sort of release, I blame my thesis) of the OpenCV library. To integrate garbage collection, I've wrapped key foreign objects with clos objects and attached a finalizer to the clos wrappers. Now, the problem is that sometimes, if you use the foreign pointer associated with the wrapper, the wrapper itself becomes no longer needed and a smart compiler might decide to make it available for garbage collection. Eg.
Is there any portable way I could prevent this? I know settings (safety 3) is supposed to stop this in SBCL, but am unsure whether this is true across implementations. Any other solution would be nice also.
Thanks
I'm busy writing a partial binding (not at all ready for any sort of release, I blame my thesis) of the OpenCV library. To integrate garbage collection, I've wrapped key foreign objects with clos objects and attached a finalizer to the clos wrappers. Now, the problem is that sometimes, if you use the foreign pointer associated with the wrapper, the wrapper itself becomes no longer needed and a smart compiler might decide to make it available for garbage collection. Eg.
(let ((foreign-object foo))
(foreign-function (foreign-pointer foreign-object)))
Note that, after foreign-pointer has been called, foreign-object is "no longer needed" from a naive point of view, and might be garbage collected before foreign-function is called (thus invalidating the foreign pointer and causing nastiness).Is there any portable way I could prevent this? I know settings (safety 3) is supposed to stop this in SBCL, but am unsure whether this is true across implementations. Any other solution would be nice also.
Thanks
Last edited by ramarren on , edited 1 time in total. Reason: Added code tags