Closed slavslavov closed 1 year ago
How about this? I didn't test it yet, but I don't see how it can't work.
Yep, this looks quite nice and exactly what I had in mind.
Just thinking do we need main_deinit? I don't have a use case for it but init/deinit usually go in pairs.
You're right. I also made some (additional) fixes. Pushed to master.
Released.
Currently all plugin functions are called for each thread but it will be good to have one which is called only once from the main thread before the other threads are created. To minimise the impact on the current design its signature may look like this:
typedef void(*F_flashmq_plugin_main_init_v2)(std::unordered_map<std::string, std::string> &auth_opts);
No global data pointer is added to keep the multi-core design of FlashMQ unchanged and in case needed, a static variable can be used as suggested in the documentation forflashmq_plugin_allocate_thread_memory
.One use case for this function would be to check which OS user is running the process.
The best place to call this function would be here:
But the main problem is
Authentication
, which is a member ofThreadData
is instantiated a few lines after this location.