CLOS object finalization
Dear everyone,
I am encapsulating foreign allocated objects within CLOS classes.
In my case, it is okay to free the memory when the garbage collector
reclaims the objects. So here is how I am finalizing my CLOS objects:
(defgeneric finalize-object (object)
(:method (object)
(declare (ignore object))
nil))
(hcl:add-special-free-action 'finalize-object)
(defclass my-class ()
())
(defmethod initialize-instance :after ((self my-class) &key)
(hcl:flag-special-free-action self))
(defmethod finalize-object ((self my-class))
;; Do whatever is needed to finalize the object here ...
;; Warning: the thread in which this code is called is unknown.
...)
FLI users: and you, how do you do this?
Do you have a different technique?
Are there any pitfalls I have missed?
I search for something already existing in LW, but I did not find
anything similar. I thought the problem wasn't so specific ...
Cheers,
Camille