GNOME Bugzilla – Bug 646783
Accessing DestroyNotify property of generics
Last modified: 2018-05-22 14:00:00 UTC
While the Vala-provided GC is proper way of handling garbage collection it is not always possible. For example reference counting in lock-free data structures requires primitives not-widely avaible such as DCAS. It means that in some cases other methods are needed to cover such edge cases. Unfortunatly it requires access to destroy notify to properly release resources.
It is possible to do in GObject by: DestroyNotify res; get ("k-destroy-func", out res); return res; but it seems to be a bit of workaround.
Having syntax to do this could also be useful for compact classes used in certain generics.
(In reply to comment #2) > Having syntax to do this could also be useful for compact classes used in > certain generics. Possibly something like [GenericMethods] proposed in bug #695050 would be better (more automatic) solution to your problem?
I'm not even sure what bug #695050 is proposing. I'd like to be able to go `destructorof(T)` and get back a DestroyNotify that is either the free_function or unref_function as appropriate. In fact, this could be implemented as a macro in C.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/190.