Clarification around clap_plugin_entry init/deinit #365
-
I am working on cleaning up some rough edges on my Rust Clap wrapper around DSO loading and entry initialization, and reading through the The spec says this about Line 38 in e292447 And about Line 55 in e292447 My initial interpretation was that because However that doesn't seem to be exactly what the spec says, and I'm wondering if it could be interpreted in a different, way so that // Host starts up and loads a plugin for the user
entry->init();
// Plugin factory is retrieved, plugin is instantiated and used, etc.
// User decides to not use the plugin for a while, and host wants to free some resources,
// so it decides to unload the whole entry since there is no instance.
entry->deinit();
// A while later, user wants to use the plugin again (or another plugin in the same DSO),
// so the host needs to initialize the entry again.
entry->init();
// And so on... I can see this interpretation making more sense, since (at least on Linux) a That would mean hosts following my first interpretation would either need to prevent a plugin's DSO to be loaded a second time after it's been However, my second interpretation seems to clash a good bit with the parts of the spec I quoted above, even though it doesn't seem to be explicitly forbidden either. So I guess my main question is, is my second interpretation allowed? Also, not completely related but adding to the confusion, the spec marks both Line 34 in e292447 To me, "thread safe" means that the methods can be called simultaneously from multiple threads, which seems completely at odds with the fact that these can be called only once. So far I've interpreted it as Thanks in advance! 🙂 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
IMHO it is just that these two steps:
and
are seen as atomic steps. A host that scans all plugins will unload them all after inspection. Regarding the |
Beta Was this translation helpful? Give feedback.
IMHO it is just that these two steps:
init()
and
deinit()
and unload DSOare seen as atomic steps. A host that scans all plugins will unload them all after inspection.
After unloading the DSO the process is in the same state as if the DSO wasn't loaded at all.
Regarding the
thread-safe
attribute: as a plugin writer you should not make assumptions about which thread callsinit()
ordeinit()
(like: "init() is called always called in the GUI thread"). It can be any thread (or probably even different ones).