Results 1 to 3 of 3

Thread: Custom Event or Queued Connection ?

  1. #1
    Join Date
    Nov 2006
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Custom Event or Queued Connection ?

    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.
    Last edited by vishwanath; 22nd November 2006 at 13:08.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Custom Event or Queued Connection ?

    In general queued connections are implemented using events, so eventually, you'll be using the same mechanism, so pick one which is easier to use for you. Of course you'll need to make your manager inherit QObject or make a small QObject which will just act as a receiver to signals/events and call the manager's methods itself. The problem I see is that you have to be using QObjects to make that all working using the signal approach and I feel using pthreads directly can confuse the connection framework so it'll probably be safer to go with custom events.

  3. #3
    Join Date
    Nov 2006
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Custom Event or Queued Connection ?

    hi thanks for your suggestion.. I will go ahead with custom events

Similar Threads

  1. QDockWidget-title
    By moowy in forum Qt Programming
    Replies: 18
    Last Post: 23rd April 2014, 21:13
  2. delete custom event
    By Dmitry in forum Qt Programming
    Replies: 1
    Last Post: 15th October 2006, 17:55
  3. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 22:55
  4. Replies: 16
    Last Post: 7th March 2006, 16:57
  5. queued signal/slot connection with QList<int>
    By smalls in forum Qt Programming
    Replies: 2
    Last Post: 7th February 2006, 15:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.