Hi,
I am working on a plugin based system. Each plugin will run in a different thread. And the thread uses pthreads ( legacy code and don't intend to chage it ). Each thread is assigned a callback fucntion of the PluginManager.
Now when the plugin wants to communicate something to the PluginManager ; it call the callback function. Now the PluginManager needs to communicate to GUI.
Currently, we are calling the GUI ( Qt ) code from the callback function itself. And it works fine (as, for now there is only a single plugin ). But when there are more that one plugins then, we need to set mutex for the callback functions. And each thread has to wait for the mutex to get released , Since the callback function calls the Qt code, each thread has to wait more than necessary.
So I was thinking of using Custom Events or Queued connection. And I am confused which method to go with. Or what are the pros and cons of each ?
What I want after the implementation is, that the callback will raise an event or signal and just leave( so that the other threads need not wait for the GUI code to get executed ). And the event handler has to be invoked later. Ya, mostly like a Event mechanism.
Could you guys please help ?
Edited:
I forgot to tell that the PluginManager is not QObject sublcass, so is Queued Connection an option ? Since only QObject subclasses can emit a signal.
Bookmarks