For reasons, backwards compatibility mainly, rather than have my list of plugins be a list of function pointers, I would like them to be a list of PluginFactories and I'd like them to be created lazily. In code terms:
I then work with PLUGINS whenever I need access to my plugins. If I never access my PLUGINS, then the Lazy code is never invoked. (BTW: Lazy is nice from a performance point of view, but I'm mainly using it to workaround the limitation that the distributed slice must be const/static.)
That works fine on OS X, Linux (arm and amd), but doesn't work on windows. The code compiles and runs, but on windows none of my plugins are registered and so I get runtime errors about missing plugins.
Before I dig into this too much. Am I expecting too much of linkme and once_cell? Is this a reasonable thing to do or am I just lucky that it works on non-windows platforms and really this is just a silly thing to try?
I'm concerned that trying to finesse away the requirement for const/static via Lazy is a potential source of problems. I wonder if I'm just lucky with the initialisation order on non-windows platforms.
For reasons, backwards compatibility mainly, rather than have my list of plugins be a list of function pointers, I would like them to be a list of PluginFactories and I'd like them to be created lazily. In code terms:
is my list of plugins.
Each plugin registers from a macro with something like:
I then work with PLUGINS whenever I need access to my plugins. If I never access my PLUGINS, then the Lazy code is never invoked. (BTW: Lazy is nice from a performance point of view, but I'm mainly using it to workaround the limitation that the distributed slice must be const/static.)
That works fine on OS X, Linux (arm and amd), but doesn't work on windows. The code compiles and runs, but on windows none of my plugins are registered and so I get runtime errors about missing plugins.
Before I dig into this too much. Am I expecting too much of linkme and once_cell? Is this a reasonable thing to do or am I just lucky that it works on non-windows platforms and really this is just a silly thing to try?
I'm concerned that trying to finesse away the requirement for
const/static
via Lazy is a potential source of problems. I wonder if I'm just lucky with the initialisation order on non-windows platforms.