dynamix icon indicating copy to clipboard operation
dynamix copied to clipboard

Auto-unregister globally defined features

Open iboB opened this issue 1 year ago • 0 comments

Currently globally defined features like messages (and in the near future facts) are never unregistered.

This is because of the assumption that they will not come from plugins. A plugin can define mixins, but it should not define new messages. There seems to be no use case for this. If a use case is identified, we should take some precautions to unregister these features, otherwise they will leak when the plugin is unloaded.

Possible ways how this can be done:

  • Add a domain to feature_info (like there is one in the mixin info) and unregister with a global instance holder, like the one for mixins and type classes. Feature info will become "fatter"
  • Add a global instance holder, but use the domain tag instead of a domain member in the info. This means that macros which define features will also have to have the domain tag as an argument which will make them more unpleasant (as if they aren't enough unpleasant already)
  • Add ref count to features in domain which is increased when a mixin is registered and decreased when it is unregistered. If it reaches zero, the feature is unregistered as well

Option 2 seems the worst to me, but I can't decide between 1 and 3.

iboB avatar Apr 04 '23 06:04 iboB